Search in sources :

Example 51 with AnnotationConfigWebApplicationContext

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

the class WebServicesAutoConfigurationTests method load.

private void load(Class<?> config, String... environment) {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    EnvironmentTestUtils.addEnvironment(context, environment);
    context.register(config);
    context.refresh();
    this.context = context;
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext)

Example 52 with AnnotationConfigWebApplicationContext

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

the class ConditionalOnNotWebApplicationTests method testNotWebApplicationWithServletContext.

@Test
public void testNotWebApplicationWithServletContext() {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(NotWebApplicationConfiguration.class);
    ctx.setServletContext(new MockServletContext());
    ctx.refresh();
    this.context = ctx;
    assertThat(this.context.getBeansOfType(String.class)).isEmpty();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.Test)

Example 53 with AnnotationConfigWebApplicationContext

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

the class SpringDataWebAutoConfigurationTests method webSupportIsAutoConfiguredInWebApplicationContexts.

@Test
public void webSupportIsAutoConfiguredInWebApplicationContexts() {
    this.context = new AnnotationConfigWebApplicationContext();
    ((AnnotationConfigWebApplicationContext) this.context).register(SpringDataWebAutoConfiguration.class);
    this.context.refresh();
    ((AnnotationConfigWebApplicationContext) this.context).setServletContext(new MockServletContext());
    Map<String, PageableHandlerMethodArgumentResolver> beans = this.context.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
    assertThat(beans).hasSize(1);
}
Also used : PageableHandlerMethodArgumentResolver(org.springframework.data.web.PageableHandlerMethodArgumentResolver) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.Test)

Example 54 with AnnotationConfigWebApplicationContext

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

the class Neo4jDataAutoConfigurationTests method load.

private void load(Class<?> config, String... environment) {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(ctx, environment);
    if (config != null) {
        ctx.register(config);
    }
    ctx.register(PropertyPlaceholderAutoConfiguration.class, TransactionAutoConfiguration.class, Neo4jDataAutoConfiguration.class);
    ctx.refresh();
    this.context = ctx;
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext)

Example 55 with AnnotationConfigWebApplicationContext

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

the class HypermediaAutoConfigurationTests method linkDiscoverersCreated.

@Test
public void linkDiscoverersCreated() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(BaseConfig.class);
    this.context.refresh();
    LinkDiscoverers discoverers = this.context.getBean(LinkDiscoverers.class);
    assertThat(discoverers).isNotNull();
    LinkDiscoverer discoverer = discoverers.getLinkDiscovererFor(MediaTypes.HAL_JSON);
    assertThat(HalLinkDiscoverer.class.isInstance(discoverer)).isTrue();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) LinkDiscoverer(org.springframework.hateoas.LinkDiscoverer) HalLinkDiscoverer(org.springframework.hateoas.hal.HalLinkDiscoverer) MockServletContext(org.springframework.mock.web.MockServletContext) LinkDiscoverers(org.springframework.hateoas.LinkDiscoverers) Test(org.junit.Test)

Aggregations

AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)192 Test (org.junit.Test)129 MockServletContext (org.springframework.mock.web.MockServletContext)80 MockMvc (org.springframework.test.web.servlet.MockMvc)25 URI (java.net.URI)23 HashMap (java.util.HashMap)23 MapPropertySource (org.springframework.core.env.MapPropertySource)23 StandardEnvironment (org.springframework.core.env.StandardEnvironment)23 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)21 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)16 ProtobufMessageSerDe (com.kixeye.chassis.transport.serde.converter.ProtobufMessageSerDe)15 RestTemplate (org.springframework.web.client.RestTemplate)15 ServiceError (com.kixeye.chassis.transport.dto.ServiceError)14 JsonJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.JsonJacksonMessageSerDe)14 XmlMessageSerDe (com.kixeye.chassis.transport.serde.converter.XmlMessageSerDe)14 YamlJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.YamlJacksonMessageSerDe)14 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)13 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)13 QueuingWebSocketListener (com.kixeye.chassis.transport.websocket.QueuingWebSocketListener)9 WebSocketMessageRegistry (com.kixeye.chassis.transport.websocket.WebSocketMessageRegistry)9