Java Code Examples for org.springframework.context.ConfigurableApplicationContext#setParent()
The following examples show how to use
org.springframework.context.ConfigurableApplicationContext#setParent() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud-commons File: EnvironmentDecryptApplicationInitializerTests.java License: Apache License 2.0 | 6 votes |
@Test public void testDecryptNonStandardParent() { ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(); EnvironmentDecryptApplicationInitializer initializer = new EnvironmentDecryptApplicationInitializer( Encryptors.noOpText()); TestPropertyValues.of("key:{cipher}value").applyTo(ctx); ApplicationContext ctxParent = mock(ApplicationContext.class); when(ctxParent.getEnvironment()).thenReturn(mock(Environment.class)); ctx.setParent(ctxParent); initializer.initialize(ctx); then(ctx.getEnvironment().getProperty("key")).isEqualTo("value"); }
Example 2
Source Project: joyrpc File: SpringMultiContextTest.java License: Apache License 2.0 | 5 votes |
@Test public void testPlugin() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(SpringLoaderAutoConfiguration.class, ConsumerAutoConfiguration.class); context.setParent(parent); context.start(); ExtensionPoint<Consumer, String> consumer = new ExtensionPointLazy<Consumer, String>(Consumer.class); Assert.assertEquals(consumer.size(), 2); Consumer target = consumer.get(); Assert.assertNotNull(target); context.close(); Assert.assertEquals(consumer.size(), 1); target = consumer.get(); Assert.assertNotNull(target); }