Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext.destroy()


public class ReproTests {

  public static void main(String[] args) {
    while(true) {
      AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfigClass.class);
      ctx.destroy();
    }
  }

}
View Full Code Here


  @Test
  public void destroyContext() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
    Config config = ctx.getBean(Config.class);
    assertThat(config, instanceOf(DisposableBean.class));
    ctx.destroy();
  }

  /**
   * The DisposableBeanMethodInterceptor in ConfigurationClassEnhancer
   * should be careful to invoke any explicit super-implementation of
View Full Code Here

  @Test
  public void destroyExplicitDisposableBeanConfig() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DisposableConfig.class);
    DisposableConfig config = ctx.getBean(DisposableConfig.class);
    assertThat(config.destroyed, is(false));
    ctx.destroy();
    assertThat("DisposableConfig.destroy() was not invoked", config.destroyed, is(true));
  }


  @Configuration
View Full Code Here

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);

        assertNotNull(context.getBean(GraphDatabaseService.class));
        assertNotNull(context.getBean(GraphChangeReader.class));

        context.destroy();
    }
}
View Full Code Here

    SolrServer server2 = context.getBean("core2", SolrServer.class);
    assertNotNull(server2);

    Thread.sleep(TimeUnit.SECONDS.toMillis(5));
    context.destroy();
    context.close();
  }
}
View Full Code Here

    template.sendBody("direct:configurer", "Configurer works!");
    template.sendBody("direct:router", "Router works!");
    template.sendBody("direct:props", "...");

    context.destroy();
  }
}
View Full Code Here

    SolrServer server2 = context.getBean("core2", SolrServer.class);
    assertNotNull(server2);

    Thread.sleep(TimeUnit.SECONDS.toMillis(5));
    context.destroy();
    context.close();
  }
}
View Full Code Here

    AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext( Config.class );
    ConfigurableListableBeanFactory beanFactory = parent.getBeanFactory();

    assertNotNull( beanFactory.getSingleton( "myBean" ) );

    parent.destroy();
    assertNull( beanFactory.getSingleton( "myBean" ) );
  }

  @Test
  public void destroySpringContextWithChild() {
View Full Code Here

    assertNotNull( parentFactory.getSingleton( "myBean" ) );
    assertNotNull( childFactory.getSingleton( "myBean" ) );
    assertNotSame( parentFactory.getSingleton( "myBean" ), childFactory.getSingleton( "myBean" ) );

    child.destroy();
    assertNotNull( parentFactory.getSingleton( "myBean" ) );
    assertNull( childFactory.getSingleton( "myBean" ) );
  }

  @Test
View Full Code Here

    Config.listener2.onCreate(Config.conn2);
    verify(Config.channel2, times(0)).queueDeclare("foo", true, false, false, null);
    verify(Config.channel2, times(0)).exchangeDeclare("bar", "direct", true, false, new HashMap<String, Object>());
    verify(Config.channel2, times(0)).queueBind("foo", "bar", "foo", null);
    context.destroy();
  }

  @Test
  public void testAddRemove() {
    Queue queue = new Queue("foo");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.