Search in sources :

Example 1 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.

the class MvcEndpointsTests method picksUpEndpointDelegatesFromParent.

@Test
public void picksUpEndpointDelegatesFromParent() throws Exception {
    StaticApplicationContext parent = new StaticApplicationContext();
    this.context.setParent(parent);
    parent.getDefaultListableBeanFactory().registerSingleton("endpoint", new TestEndpoint());
    this.endpoints.setApplicationContext(this.context);
    this.endpoints.afterPropertiesSet();
    assertThat(this.endpoints.getEndpoints()).hasSize(1);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Test(org.junit.Test)

Example 2 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-boot by spring-projects.

the class CloudFoundryEndpointHandlerMappingTests method registersCloudFoundryHealthEndpoint.

@Test
public void registersCloudFoundryHealthEndpoint() throws Exception {
    StaticApplicationContext context = new StaticApplicationContext();
    HealthEndpoint delegate = new HealthEndpoint(new OrderedHealthAggregator(), Collections.<String, HealthIndicator>emptyMap());
    CloudFoundryEndpointHandlerMapping handlerMapping = new CloudFoundryEndpointHandlerMapping(Collections.singleton(new TestHealthMvcEndpoint(delegate)), null, null);
    handlerMapping.setPrefix("/test");
    handlerMapping.setApplicationContext(context);
    handlerMapping.afterPropertiesSet();
    HandlerExecutionChain handler = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/test/health"));
    HandlerMethod handlerMethod = (HandlerMethod) handler.getHandler();
    Object handlerMethodBean = handlerMethod.getBean();
    assertThat(handlerMethodBean).isInstanceOf(CloudFoundryHealthMvcEndpoint.class);
}
Also used : HealthEndpoint(org.springframework.boot.actuate.endpoint.HealthEndpoint) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) HandlerExecutionChain(org.springframework.web.servlet.HandlerExecutionChain) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) OrderedHealthAggregator(org.springframework.boot.actuate.health.OrderedHealthAggregator) HandlerMethod(org.springframework.web.method.HandlerMethod) Test(org.junit.Test)

Example 3 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project camel by apache.

the class CamelContextFactoryBeanTest method testCustomModelJAXBContextFactory.

public void testCustomModelJAXBContextFactory() throws Exception {
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton("customModelJAXBContextFactory", CustomModelJAXBContextFactory.class);
    factory.setApplicationContext(applicationContext);
    factory.afterPropertiesSet();
    ModelJAXBContextFactory modelJAXBContextFactory = factory.getContext().getModelJAXBContextFactory();
    assertTrue(modelJAXBContextFactory instanceof CustomModelJAXBContextFactory);
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) DefaultModelJAXBContextFactory(org.apache.camel.impl.DefaultModelJAXBContextFactory) ModelJAXBContextFactory(org.apache.camel.spi.ModelJAXBContextFactory)

Example 4 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project camel by apache.

the class CamelContextFactoryBeanTest method testGetCustomUuidGenerator.

public void testGetCustomUuidGenerator() throws Exception {
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton("uuidGenerator", SimpleUuidGenerator.class);
    factory.setApplicationContext(applicationContext);
    factory.afterPropertiesSet();
    UuidGenerator uuidGenerator = factory.getContext().getUuidGenerator();
    assertTrue(uuidGenerator instanceof SimpleUuidGenerator);
}
Also used : UuidGenerator(org.apache.camel.spi.UuidGenerator) SimpleUuidGenerator(org.apache.camel.impl.SimpleUuidGenerator) ActiveMQUuidGenerator(org.apache.camel.impl.ActiveMQUuidGenerator) SimpleUuidGenerator(org.apache.camel.impl.SimpleUuidGenerator) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext)

Example 5 with StaticApplicationContext

use of org.springframework.context.support.StaticApplicationContext in project spring-framework by spring-projects.

the class ScriptTemplateViewTests method missingScriptTemplateConfig.

@Test
public void missingScriptTemplateConfig() throws Exception {
    this.expectedException.expect(ApplicationContextException.class);
    this.view.setApplicationContext(new StaticApplicationContext());
    this.expectedException.expectMessage(contains("ScriptTemplateConfig"));
}
Also used : StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) Test(org.junit.Test)

Aggregations

StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)322 Test (org.junit.jupiter.api.Test)218 lombok.val (lombok.val)159 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)59 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)39 BeforeEach (org.junit.jupiter.api.BeforeEach)36 Test (org.junit.Test)34 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)31 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)25 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)20 HashSet (java.util.HashSet)19 MockRequestContext (org.springframework.webflow.test.MockRequestContext)19 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)16 MockServletContext (org.springframework.mock.web.MockServletContext)16 MultifactorAuthenticationProviderBypassProperties (org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProviderBypassProperties)15 BeanDefinitionReader (org.springframework.beans.factory.support.BeanDefinitionReader)13 ApplicationContext (org.springframework.context.ApplicationContext)12 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 QueueChannel (org.springframework.integration.channel.QueueChannel)11