Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext refresh

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext refresh

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext refresh.

Prototype

@Override
    public void refresh() throws BeansException, IllegalStateException 

Source Link

Usage

From source file:org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializerTests.java

@Test
public void canBeUsedInApplicationContext() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(Config.class);
    new AutoConfigurationReportLoggingInitializer().initialize(context);
    context.refresh();
    assertNotNull(context.getBean(ConditionEvaluationReport.class));
}

From source file:org.springframework.cloud.gateway.test.websocket.WebSocketIntegrationTests.java

private HttpHandler createHttpHandler() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(WebSocketTestConfig.class);
    context.refresh();
    return WebHttpHandlerBuilder.applicationContext(context).build();
}

From source file:org.springframework.integration.configuration.EnableIntegrationTests.java

@Test
public void testParentChildAnnotationConfiguration() {
    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.register(ChildConfiguration.class);
    child.setParent(this.context);
    child.refresh();
    AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
    ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
    assertTrue(foo.getChannelInterceptors().contains(baz));
    assertFalse(this.output.getChannelInterceptors().contains(baz));
    child.close();//from   www. j  a  va  2  s.co m
}

From source file:org.springframework.integration.configuration.EnableIntegrationTests.java

@Test
public void testParentChildAnnotationConfigurationFromAnotherPackage() {
    AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
    child.register(org.springframework.integration.configuration2.ChildConfiguration.class);
    child.setParent(this.context);
    child.refresh();
    AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
    ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
    assertTrue(foo.getChannelInterceptors().contains(baz));
    assertFalse(this.output.getChannelInterceptors().contains(baz));
    child.close();/*ww w .  j av a  2 s .  co m*/
}