Search in sources :

Example 21 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class AbstractApplicationContext method toString.

/**
	 * Return information about this context.
	 */
@Override
public String toString() {
    StringBuilder sb = new StringBuilder(getDisplayName());
    sb.append(": startup date [").append(new Date(getStartupDate()));
    sb.append("]; ");
    ApplicationContext parent = getParent();
    if (parent == null) {
        sb.append("root of context hierarchy");
    } else {
        sb.append("parent: ").append(parent.getDisplayName());
    }
    return sb.toString();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) Date(java.util.Date)

Example 22 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.

the class JoinPointMonitorAtAspectJAspect method checkAtAspectJAspect.

private void checkAtAspectJAspect(String appContextFile) {
    ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
    ICounter counter = (ICounter) context.getBean("counter");
    assertTrue("Proxy didn't get created", counter instanceof Advised);
    counter.increment();
    JoinPointMonitorAtAspectJAspect callCountingAspect = (JoinPointMonitorAtAspectJAspect) context.getBean("monitoringAspect");
    assertEquals("Advise didn't get executed", 1, callCountingAspect.beforeExecutions);
    assertEquals("Advise didn't get executed", 1, callCountingAspect.aroundExecutions);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Advised(org.springframework.aop.framework.Advised)

Example 23 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-boot by spring-projects.

the class RemoteUrlPropertyExtractorTests method validUrl.

@Test
public void validUrl() throws Exception {
    ApplicationContext context = doTest("http://localhost:8080");
    assertThat(context.getEnvironment().getProperty("remoteUrl")).isEqualTo("http://localhost:8080");
    assertThat(context.getEnvironment().getProperty("spring.thymeleaf.cache")).isNull();
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Test(org.junit.Test)

Example 24 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-boot by spring-projects.

the class MockRestServiceServerResetTestExecutionListener method afterTestMethod.

@Override
public void afterTestMethod(TestContext testContext) throws Exception {
    ApplicationContext applicationContext = testContext.getApplicationContext();
    String[] names = applicationContext.getBeanNamesForType(MockRestServiceServer.class, false, false);
    for (String name : names) {
        applicationContext.getBean(name, MockRestServiceServer.class).reset();
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) MockRestServiceServer(org.springframework.test.web.client.MockRestServiceServer)

Example 25 with ApplicationContext

use of org.springframework.context.ApplicationContext in project spring-boot by spring-projects.

the class OverrideAutoConfigurationEnabledFalseIntegrationTest method disabledAutoConfiguration.

@Test
public void disabledAutoConfiguration() throws Exception {
    ApplicationContext context = this.context;
    assertThat(context.getBean(ExampleTestConfig.class)).isNotNull();
    this.thrown.expect(NoSuchBeanDefinitionException.class);
    context.getBean(ConfigurationPropertiesBindingPostProcessor.class);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Test(org.junit.Test)

Aggregations

ApplicationContext (org.springframework.context.ApplicationContext)532 Test (org.junit.Test)256 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)161 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)38 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)32 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)28 File (java.io.File)24 Messenger (org.springframework.scripting.Messenger)24 DataSource (javax.sql.DataSource)23 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)21 Refreshable (org.springframework.aop.target.dynamic.Refreshable)20 StubCloudConnectorTest (org.springframework.cloud.StubCloudConnectorTest)17 SchedulerException (org.quartz.SchedulerException)16 HashMap (java.util.HashMap)15 Map (java.util.Map)14 WebApplicationContext (org.springframework.web.context.WebApplicationContext)14 MovieMapper (com.mapper.MovieMapper)13 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)13 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)13 ArrayList (java.util.ArrayList)12