Example usage for org.springframework.context ConfigurableApplicationContext toString

List of usage examples for org.springframework.context ConfigurableApplicationContext toString

Introduction

In this page you can find the example usage for org.springframework.context ConfigurableApplicationContext toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.springframework.data.hadoop.admin.workflow.support.FileSystemApplicationContextFactoryTest.java

/**
 * Test method for {@link org.springframework.data.hadoop.admin.workflow.support.FileSystemApplicationContextFactory#createApplicationContext()}.
 * @throws SpringHadoopAdminWorkflowException 
 * @throws ConfigurationException /*from  w  ww  .  j a v a2s .  c  om*/
 */
@Test
public void testCreateApplicationContext() throws ConfigurationException, SpringHadoopAdminWorkflowException {
    ApplicationContext rootContext = null;
    try {
        rootContext = new ClassPathXmlApplicationContext(
                new String[] { "classpath:org/springframework/data/hadoop/admin/env-context.xml",
                        "classpath:org/springframework/data/hadoop/admin/data-source-context.xml",
                        "classpath:org/springframework/data/hadoop/admin/execution-context.xml", });
    } catch (Exception e) {
        Assert.fail("test create root application context failed." + e.getMessage());
    }
    try {
        JobRepository jobRepository = rootContext.getBean("jobRepository", JobRepository.class);
        if (jobRepository == null) {
            Assert.fail("test get JobRepository is null");
        }
    } catch (Exception e) {
        Assert.fail("test get JobRepository failed." + e.getMessage());
    }
    contextFactory.setApplicationContext(rootContext);
    File descriptor = new File(
            "src/test/resources/org/springframework/data/hadoop/admin/workflow/support/context.xml");
    File folder = descriptor.getParentFile();
    HadoopWorkflowUtils.processUploadedFile(folder);
    ClassLoader loader = HadoopWorkflowUtils.getWorkflowClassLoader(folder);
    contextFactory.setBeanClassLoader(loader);
    contextFactory.setResource(new FileSystemResource(
            "src/test/resources/org/springframework/data/hadoop/admin/workflow/support/context.xml"));
    ConfigurableApplicationContext newContext = contextFactory.createApplicationContext();
    logger.info("new context:" + newContext.toString());
    Object obj = newContext.getBean("wordcount-withscript-job");
    Assert.assertNotNull(obj);
}