@Test public void parentContextIdentical() throws Exception { SpringApplicationBuilder application = new SpringApplicationBuilder(ExampleConfig.class); application.parent(ExampleConfig.class); application.contextClass(SpyApplicationContext.class); this.context = application.run(); verify(((SpyApplicationContext) this.context).getApplicationContext()) .setParent(any(ApplicationContext.class)); }
@Test public void parentContextCreation() throws Exception { SpringApplicationBuilder application = new SpringApplicationBuilder(ChildConfig.class).contextClass(SpyApplicationContext.class); application.parent(ExampleConfig.class); this.context = application.run(); verify(((SpyApplicationContext) this.context).getApplicationContext()) .setParent(any(ApplicationContext.class)); assertThat(((SpyApplicationContext) this.context).getRegisteredShutdownHook(), equalTo(false)); }
@Test public void parentContextWithClassLoader() throws Exception { SpringApplicationBuilder application = new SpringApplicationBuilder(ChildConfig.class).contextClass(SpyApplicationContext.class); ClassLoader classLoader = new URLClassLoader(new URL[0], getClass().getClassLoader()); application.resourceLoader(new DefaultResourceLoader(classLoader)); application.parent(ExampleConfig.class); this.context = application.run(); assertThat( ((SpyApplicationContext) this.context).getResourceLoader().getClassLoader(), is(equalTo(classLoader))); }