Here are the examples of the java api org.springframework.context.ConfigurableApplicationContext.close() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
290 Examples
19
Source : SpringContextUtils.java
with Apache License 2.0
from zifangsky
with Apache License 2.0
from zifangsky
/**
* 停止应用程序
*/
public static void close() {
if (applicationContext != null) {
applicationContext.close();
}
}
19
Source : TestContext.java
with MIT License
from yuriytkach
with MIT License
from yuriytkach
@Test
public void testPropertyPlaceholderSystemOverride() {
System.setProperty("id", "35");
ConfigurableApplicationContext ctx = new ClreplacedPathXmlApplicationContext("spring.xml", "loggers.xml", "db.xml");
Client client = ctx.getBean(Client.clreplaced);
ctx.close();
replacedertEquals("35", client.getId());
}
19
Source : TestDBLogger.java
with MIT License
from yuriytkach
with MIT License
from yuriytkach
@After
public void closeContext() {
ctx.close();
}
19
Source : App.java
with MIT License
from yuriytkach
with MIT License
from yuriytkach
public static void main(String[] args) {
ConfigurableApplicationContext ctx = new ClreplacedPathXmlApplicationContext("spring.xml", "loggers.xml", "aspects.xml", "db.xml");
App app = (App) ctx.getBean("app");
System.out.println(app.startupMessage);
Client client = ctx.getBean(Client.clreplaced);
System.out.println("Client says: " + client.getGreeting());
app.logEvents(ctx);
ctx.close();
}
19
Source : SampleWebSocketsApplicationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void echoEndpoint() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.clreplaced, PropertyPlaceholderAutoConfiguration.clreplaced).properties("websocket.uri:ws://localhost:" + this.port + "/echo/websocket").run("--spring.main.web-application-type=none");
long count = context.getBean(ClientConfiguration.clreplaced).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.clreplaced).messagePayload;
context.close();
replacedertThat(count).isEqualTo(0);
replacedertThat(messagePayloadReference.get()).isEqualTo("Did you say \"Hello world!\"?");
}
19
Source : SampleWebSocketsApplicationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void reverseEndpoint() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.clreplaced, PropertyPlaceholderAutoConfiguration.clreplaced).properties("websocket.uri:ws://localhost:" + this.port + "/reverse").run("--spring.main.web-application-type=none");
long count = context.getBean(ClientConfiguration.clreplaced).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.clreplaced).messagePayload;
context.close();
replacedertThat(count).isEqualTo(0);
replacedertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
}
19
Source : CustomContainerWebSocketsApplicationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void echoEndpoint() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.clreplaced, PropertyPlaceholderAutoConfiguration.clreplaced).properties("websocket.uri:ws://localhost:" + this.port + "/ws/echo/websocket").run("--spring.main.web-application-type=none");
long count = context.getBean(ClientConfiguration.clreplaced).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.clreplaced).messagePayload;
context.close();
replacedertThat(count).isEqualTo(0);
replacedertThat(messagePayloadReference.get()).isEqualTo("Did you say \"Hello world!\"?");
}
19
Source : CustomContainerWebSocketsApplicationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void reverseEndpoint() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.clreplaced, PropertyPlaceholderAutoConfiguration.clreplaced).properties("websocket.uri:ws://localhost:" + this.port + "/ws/reverse").run("--spring.main.web-application-type=none");
long count = context.getBean(ClientConfiguration.clreplaced).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.clreplaced).messagePayload;
context.close();
replacedertThat(count).isEqualTo(0);
replacedertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
}
19
Source : SampleAtmosphereApplicationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void chatEndpoint() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.clreplaced, PropertyPlaceholderAutoConfiguration.clreplaced).properties("websocket.uri:ws://localhost:" + this.port + "/chat/websocket").run("--spring.main.web-application-type=none");
long count = context.getBean(ClientConfiguration.clreplaced).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.clreplaced).messagePayload;
context.close();
replacedertThat(count).isEqualTo(0L);
replacedertThat(messagePayloadReference.get()).contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
}
19
Source : RestartScopeInitializerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void restartScope() {
createCount = new AtomicInteger();
refreshCount = new AtomicInteger();
ConfigurableApplicationContext context = runApplication();
context.close();
context = runApplication();
context.close();
replacedertThat(createCount.get()).isEqualTo(1);
replacedertThat(refreshCount.get()).isEqualTo(2);
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void hsqlServerIsNotShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.hsqldb.jdbcDriver", "jdbc:hsqldb:hsql://localhost", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, never()).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void autoConfiguredExternalDataSourceIsNotShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.postgresql.Driver", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, never()).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void derbyClientIsNotShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, never()).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void inMemoryH2IsShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.h2.Driver", "jdbc:h2:mem:test", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, times(1)).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void h2ServerIsNotShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.h2.Driver", "jdbc:h2:hsql://localhost", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, never()).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void inMemoryDerbyIsShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.apache.derby.jdbc.EmbeddedDriver", "jdbc:derby:memory:test", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, times(1)).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void inMemoryHsqlIsShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:test", DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, times(1)).execute("SHUTDOWN");
}
19
Source : DevToolsPooledDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void autoConfiguredInMemoryDataSourceIsShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext(DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement).execute("SHUTDOWN");
}
19
Source : DevToolsEmbeddedDataSourceAutoConfigurationTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void autoConfiguredDataSourceIsNotShutdown() throws SQLException {
ConfigurableApplicationContext context = createContext(DataSourceAutoConfiguration.clreplaced, DataSourceSpyConfiguration.clreplaced);
Statement statement = configureDataSourceBehavior(context.getBean(DataSource.clreplaced));
context.close();
verify(statement, never()).execute("SHUTDOWN");
}
19
Source : Restarter.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
/**
* Stop the application.
* @throws Exception in case of errors
*/
protected void stop() throws Exception {
this.logger.debug("Stopping application");
this.stopLock.lock();
try {
for (ConfigurableApplicationContext context : this.rootContexts) {
context.close();
this.rootContexts.remove(context);
}
cleanupCaches();
if (this.forceReferenceCleanup) {
forceReferenceCleanup();
}
} finally {
this.stopLock.unlock();
}
System.gc();
System.runFinalization();
}
19
Source : ConfigFileApplicationListenerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void propertySourceAnnotation() {
SpringApplication application = new SpringApplication(WithPropertySource.clreplaced);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
replacedertThat(property).isEqualTo("fromspecificlocation");
property = context.getEnvironment().getProperty("my.property");
replacedertThat(property).isEqualTo("fromapplicationproperties");
replacedertThat(context.getEnvironment()).has(matchingPropertySource("clreplaced path resource " + "[specificlocation.properties]"));
context.close();
}
19
Source : ConfigFileApplicationListenerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void propertySourceAnnotationWithName() {
SpringApplication application = new SpringApplication(WithPropertySourceAndName.clreplaced);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
replacedertThat(property).isEqualTo("fromspecificlocation");
replacedertThat(context.getEnvironment()).has(matchingPropertySource("foo"));
context.close();
}
19
Source : ConfigFileApplicationListenerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void propertySourceAnnotationMultipleLocations() {
SpringApplication application = new SpringApplication(WithPropertySourceMultipleLocations.clreplaced);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
replacedertThat(property).isEqualTo("frommorepropertiesfile");
replacedertThat(context.getEnvironment()).has(matchingPropertySource("clreplaced path resource " + "[specificlocation.properties]"));
context.close();
}
19
Source : ConfigFileApplicationListenerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void propertySourceAnnotationAndNonActiveProfile() {
SpringApplication application = new SpringApplication(WithPropertySourceAndProfile.clreplaced);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("my.property");
replacedertThat(property).isEqualTo("fromapplicationproperties");
replacedertThat(context.getEnvironment()).doesNotHave(matchingPropertySource("clreplacedpath:" + "/enableprofile-myprofile.properties"));
context.close();
}
19
Source : ConfigFileApplicationListenerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void propertySourceAnnotationInProfile() {
SpringApplication application = new SpringApplication(WithPropertySourceInProfile.clreplaced);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run("--spring.profiles.active=myprofile");
String property = context.getEnvironment().getProperty("the.property");
replacedertThat(property).isEqualTo("frompropertiesfile");
replacedertThat(context.getEnvironment()).has(matchingPropertySource("clreplaced path resource " + "[enableprofile.properties]"));
replacedertThat(context.getEnvironment()).doesNotHave(matchingPropertySource("clreplacedpath:/" + "enableprofile-myprofile.properties"));
context.close();
}
19
Source : ConfigFileApplicationListenerTests.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
@Test
public void propertySourceAnnotationMultipleLocationsAndName() {
SpringApplication application = new SpringApplication(WithPropertySourceMultipleLocationsAndName.clreplaced);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext context = application.run();
String property = context.getEnvironment().getProperty("the.property");
replacedertThat(property).isEqualTo("frommorepropertiesfile");
replacedertThat(context.getEnvironment()).has(matchingPropertySource("foo"));
context.close();
}
19
Source : SpringContextServer.java
with Apache License 2.0
from yfh0918
with Apache License 2.0
from yfh0918
@Override
public void stop() throws Exception {
ConfigurableApplicationContext context = SpringContextHealper.getApplicationContext();
if (context != null) {
context.close();
}
}
19
Source : TestEnableBootstap.java
with MIT License
from wuyouzhuguli
with MIT License
from wuyouzhuguli
public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestEnableBootstap.clreplaced).web(WebApplicationType.NONE).run(args);
String hello = context.getBean("hello", String.clreplaced);
System.out.println("hello Bean: " + hello);
context.close();
}
19
Source : ServiceBootstrap.java
with MIT License
from wuyouzhuguli
with MIT License
from wuyouzhuguli
public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ServiceBootstrap.clreplaced).web(WebApplicationType.NONE).run(args);
TestService testService = context.getBean("testService", TestService.clreplaced);
System.out.println("TestService Bean: " + testService);
context.close();
}
19
Source : EnableAutoConfigurationBootstrap.java
with MIT License
from wuyouzhuguli
with MIT License
from wuyouzhuguli
public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(EnableAutoConfigurationBootstrap.clreplaced).web(WebApplicationType.NONE).run(args);
String hello = context.getBean("hello", String.clreplaced);
System.out.println("hello Bean: " + hello);
context.close();
}
19
Source : XmlWebApplicationContextTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void initializingBeanAndInitMethod() throws Exception {
replacedertFalse(InitAndIB.constructed);
InitAndIB iib = (InitAndIB) this.applicationContext.getBean("init-and-ib");
replacedertTrue(InitAndIB.constructed);
replacedertTrue(iib.afterPropertiesSetInvoked && iib.initMethodInvoked);
replacedertTrue(!iib.destroyed && !iib.customDestroyed);
this.applicationContext.close();
replacedertTrue(!iib.destroyed && !iib.customDestroyed);
ConfigurableApplicationContext parent = (ConfigurableApplicationContext) this.applicationContext.getParent();
parent.close();
replacedertTrue(iib.destroyed && iib.customDestroyed);
parent.close();
replacedertTrue(iib.destroyed && iib.customDestroyed);
}
19
Source : ResourceBundleViewResolver.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Close the bundle View factories on context shutdown.
*/
@Override
public void destroy() throws BeansException {
for (ConfigurableApplicationContext factory : this.bundleCache.values()) {
factory.close();
}
this.localeCache.clear();
this.bundleCache.clear();
}
19
Source : JmsListenerAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void metaAnnotationIsDiscovered() throws Exception {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.clreplaced, MetaAnnotationTestBean.clreplaced);
try {
JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.clreplaced);
replacedertEquals("one container should have been registered", 1, factory.getListenerContainers().size());
JmsListenerEndpoint endpoint = factory.getListenerContainers().get(0).getEndpoint();
replacedertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.clreplaced, endpoint.getClreplaced());
MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
replacedertEquals(MetaAnnotationTestBean.clreplaced, methodEndpoint.getBean().getClreplaced());
replacedertEquals(MetaAnnotationTestBean.clreplaced.getMethod("handleIt", String.clreplaced), methodEndpoint.getMethod());
replacedertEquals(MetaAnnotationTestBean.clreplaced.getMethod("handleIt", String.clreplaced), methodEndpoint.getMostSpecificMethod());
replacedertEquals("metaTestQueue", ((AbstractJmsListenerEndpoint) endpoint).getDestination());
} finally {
context.close();
}
}
19
Source : JmsListenerAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void simpleMessageListener() throws Exception {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.clreplaced, SimpleMessageListenerTestBean.clreplaced);
JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.clreplaced);
replacedertEquals("One container should have been registered", 1, factory.getListenerContainers().size());
MessageListenerTestContainer container = factory.getListenerContainers().get(0);
JmsListenerEndpoint endpoint = container.getEndpoint();
replacedertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.clreplaced, endpoint.getClreplaced());
MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
replacedertEquals(SimpleMessageListenerTestBean.clreplaced, methodEndpoint.getBean().getClreplaced());
replacedertEquals(SimpleMessageListenerTestBean.clreplaced.getMethod("handleIt", String.clreplaced), methodEndpoint.getMethod());
replacedertEquals(SimpleMessageListenerTestBean.clreplaced.getMethod("handleIt", String.clreplaced), methodEndpoint.getMostSpecificMethod());
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
methodEndpoint.setupListenerContainer(listenerContainer);
replacedertNotNull(listenerContainer.getMessageListener());
replacedertTrue("Should have been started " + container, container.isStarted());
// Close and stop the listeners
context.close();
replacedertTrue("Should have been stopped " + container, container.isStopped());
}
19
Source : EnableJmsTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void lazyComponent() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsDefaultContainerFactoryConfig.clreplaced, LazyBean.clreplaced);
JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.clreplaced);
replacedertEquals(0, defaultFactory.getListenerContainers().size());
// trigger lazy resolution
context.getBean(LazyBean.clreplaced);
replacedertEquals(1, defaultFactory.getListenerContainers().size());
MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0);
replacedertTrue("Should have been started " + container, container.isStarted());
// close and stop the listeners
context.close();
replacedertTrue("Should have been stopped " + container, container.isStopped());
}
19
Source : JCacheCustomInterceptorTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@After
public void tearDown() {
if (ctx != null) {
ctx.close();
}
}
19
Source : AnnotationDrivenBeanDefinitionParserTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@After
public void closeApplicationContext() {
context.close();
}
19
Source : ThreadPoolExecutorFactoryBeanTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void defaultExecutor() throws Exception {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.clreplaced);
ExecutorService executor = context.getBean(ExecutorService.clreplaced);
FutureTask<String> task = new FutureTask<>(() -> "foo");
executor.execute(task);
replacedertEquals("foo", task.get());
context.close();
}
19
Source : AsyncAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void threadNamePrefix() {
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.clreplaced);
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("testExecutor");
executor.afterPropertiesSet();
processorDefinition.getPropertyValues().add("executor", executor);
ConfigurableApplicationContext context = initContext(processorDefinition);
ITestBean testBean = context.getBean("target", ITestBean.clreplaced);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
replacedertTrue(asyncThread.getName().startsWith("testExecutor"));
context.close();
}
19
Source : AsyncAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void proxyCreated() {
ConfigurableApplicationContext context = initContext(new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.clreplaced));
Object target = context.getBean("target");
replacedertTrue(AopUtils.isAopProxy(target));
context.close();
}
19
Source : AsyncAnnotationBeanPostProcessorTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void invokedAsynchronously() {
ConfigurableApplicationContext context = initContext(new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.clreplaced));
ITestBean testBean = context.getBean("target", ITestBean.clreplaced);
testBean.test();
Thread mainThread = Thread.currentThread();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
replacedertNotSame(mainThread, asyncThread);
context.close();
}
19
Source : MBeanExporterTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testAutodetectLazyMBeans() throws Exception {
ConfigurableApplicationContext ctx = load("autodetectLazyMBeans.xml");
try {
ctx.getBean("exporter");
MBeanServer server = ctx.getBean("server", MBeanServer.clreplaced);
ObjectName oname = ObjectNameManager.getInstance("spring:mbean=true");
replacedertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "Rob Harrop", name);
oname = ObjectNameManager.getInstance("spring:mbean=another");
replacedertNotNull(server.getObjectInstance(oname));
name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "Juergen Hoeller", name);
} finally {
ctx.close();
}
}
19
Source : MBeanExporterTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void testAutodetectNoMBeans() throws Exception {
ConfigurableApplicationContext ctx = load("autodetectNoMBeans.xml");
try {
ctx.getBean("exporter");
} finally {
ctx.close();
}
}
19
Source : AnnotationLazyInitMBeanTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void componentScan() throws Exception {
ConfigurableApplicationContext ctx = new ClreplacedPathXmlApplicationContext("org/springframework/jmx/export/annotation/componentScan.xml");
try {
MBeanServer server = (MBeanServer) ctx.getBean("server");
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
replacedertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
replacedertNull(name);
} finally {
ctx.close();
}
}
19
Source : AnnotationLazyInitMBeanTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void lazyNaming() throws Exception {
ConfigurableApplicationContext ctx = new ClreplacedPathXmlApplicationContext("org/springframework/jmx/export/annotation/lazyNaming.xml");
try {
MBeanServer server = (MBeanServer) ctx.getBean("server");
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
replacedertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "TEST", name);
} finally {
ctx.close();
}
}
19
Source : AnnotationLazyInitMBeanTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void lazyreplacedembling() throws Exception {
System.setProperty("domain", "bean");
ConfigurableApplicationContext ctx = new ClreplacedPathXmlApplicationContext("org/springframework/jmx/export/annotation/lazyreplacedembling.xml");
try {
MBeanServer server = (MBeanServer) ctx.getBean("server");
ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean4");
replacedertNotNull(server.getObjectInstance(oname));
String name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "TEST", name);
oname = ObjectNameManager.getInstance("bean:name=testBean5");
replacedertNotNull(server.getObjectInstance(oname));
name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "FACTORY", name);
oname = ObjectNameManager.getInstance("spring:mbean=true");
replacedertNotNull(server.getObjectInstance(oname));
name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "Rob Harrop", name);
oname = ObjectNameManager.getInstance("spring:mbean=another");
replacedertNotNull(server.getObjectInstance(oname));
name = (String) server.getAttribute(oname, "Name");
replacedertEquals("Invalid name returned", "Juergen Hoeller", name);
} finally {
System.clearProperty("domain");
ctx.close();
}
}
19
Source : AbstractJmxTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Override
protected final void onTearDown() throws Exception {
if (ctx != null) {
ctx.close();
}
}
19
Source : SerializableBeanFactoryMemoryLeakTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
private void replacedertFactoryCountThroughoutLifecycle(ConfigurableApplicationContext ctx) throws Exception {
replacedertThat(serializableFactoryCount(), equalTo(0));
try {
ctx.refresh();
replacedertThat(serializableFactoryCount(), equalTo(1));
ctx.close();
} catch (BeanCreationException ex) {
// ignore - this is expected on refresh() for failure case tests
} finally {
replacedertThat(serializableFactoryCount(), equalTo(0));
}
}
19
Source : Spr10546Tests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@After
public void closeContext() {
if (context != null) {
context.close();
}
}
19
Source : DestroyMethodInferenceTests.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Test
public void beanMethods() {
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(Config.clreplaced);
WithExplicitDestroyMethod c0 = ctx.getBean(WithExplicitDestroyMethod.clreplaced);
WithLocalCloseMethod c1 = ctx.getBean("c1", WithLocalCloseMethod.clreplaced);
WithLocalCloseMethod c2 = ctx.getBean("c2", WithLocalCloseMethod.clreplaced);
WithInheritedCloseMethod c3 = ctx.getBean("c3", WithInheritedCloseMethod.clreplaced);
WithInheritedCloseMethod c4 = ctx.getBean("c4", WithInheritedCloseMethod.clreplaced);
WithInheritedCloseMethod c5 = ctx.getBean("c5", WithInheritedCloseMethod.clreplaced);
WithNoCloseMethod c6 = ctx.getBean("c6", WithNoCloseMethod.clreplaced);
WithLocalShutdownMethod c7 = ctx.getBean("c7", WithLocalShutdownMethod.clreplaced);
WithInheritedCloseMethod c8 = ctx.getBean("c8", WithInheritedCloseMethod.clreplaced);
WithDisposableBean c9 = ctx.getBean("c9", WithDisposableBean.clreplaced);
replacedertThat(c0.closed, is(false));
replacedertThat(c1.closed, is(false));
replacedertThat(c2.closed, is(false));
replacedertThat(c3.closed, is(false));
replacedertThat(c4.closed, is(false));
replacedertThat(c5.closed, is(false));
replacedertThat(c6.closed, is(false));
replacedertThat(c7.closed, is(false));
replacedertThat(c8.closed, is(false));
replacedertThat(c9.closed, is(false));
ctx.close();
replacedertThat("c0", c0.closed, is(true));
replacedertThat("c1", c1.closed, is(true));
replacedertThat("c2", c2.closed, is(true));
replacedertThat("c3", c3.closed, is(true));
replacedertThat("c4", c4.closed, is(true));
replacedertThat("c5", c5.closed, is(true));
replacedertThat("c6", c6.closed, is(false));
replacedertThat("c7", c7.closed, is(true));
replacedertThat("c8", c8.closed, is(false));
replacedertThat("c9", c9.closed, is(true));
}
See More Examples