Search in sources :

Example 21 with AnnotationConfigWebApplicationContext

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

the class MultipleResourceServerConfigurationTests method orderIsUnchangedWhenThereAreMultipleResourceServerConfigurations.

@Test
public void orderIsUnchangedWhenThereAreMultipleResourceServerConfigurations() {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(DoubleResourceConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "security.oauth2.resource.tokenInfoUri:http://example.com", "security.oauth2.client.clientId=acme");
    this.context.refresh();
    assertThat(this.context.getBean("adminResources", ResourceServerConfiguration.class).getOrder()).isEqualTo(3);
    assertThat(this.context.getBean("otherResources", ResourceServerConfiguration.class).getOrder()).isEqualTo(4);
}
Also used : ResourceServerConfiguration(org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Example 22 with AnnotationConfigWebApplicationContext

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

the class FacebookAutoConfigurationTests method expectedSocialBeansCreated.

@Test
public void expectedSocialBeansCreated() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.social.facebook.appId:12345");
    EnvironmentTestUtils.addEnvironment(this.context, "spring.social.facebook.appSecret:secret");
    this.context.register(FacebookAutoConfiguration.class);
    this.context.register(SocialWebAutoConfiguration.class);
    this.context.refresh();
    assertConnectionFrameworkBeans();
    assertThat(this.context.getBean(Facebook.class)).isNotNull();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Example 23 with AnnotationConfigWebApplicationContext

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

the class LinkedInAutoConfigurationTests method expectedSocialBeansCreated.

@Test
public void expectedSocialBeansCreated() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.social.linkedin.appId:12345");
    EnvironmentTestUtils.addEnvironment(this.context, "spring.social.linkedin.appSecret:secret");
    this.context.register(LinkedInAutoConfiguration.class);
    this.context.register(SocialWebAutoConfiguration.class);
    this.context.refresh();
    assertConnectionFrameworkBeans();
    assertThat(this.context.getBean(LinkedIn.class)).isNotNull();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Example 24 with AnnotationConfigWebApplicationContext

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

the class TwitterAutoConfigurationTests method expectedSocialBeansCreated.

@Test
public void expectedSocialBeansCreated() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.social.twitter.appId:12345");
    EnvironmentTestUtils.addEnvironment(this.context, "spring.social.twitter.appSecret:secret");
    this.context.register(TwitterAutoConfiguration.class);
    this.context.register(SocialWebAutoConfiguration.class);
    this.context.refresh();
    assertConnectionFrameworkBeans();
    assertThat(this.context.getBean(Twitter.class)).isNotNull();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Example 25 with AnnotationConfigWebApplicationContext

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

the class DispatcherServletAutoConfigurationTests method registrationOverrideWithDispatcherServletWrongName.

// If a DispatcherServlet instance is registered with a name different
// from the default one, we're registering one anyway
@Test
public void registrationOverrideWithDispatcherServletWrongName() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(CustomDispatcherServletWrongName.class, DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    ServletRegistrationBean<?> registration = this.context.getBean(ServletRegistrationBean.class);
    assertThat(registration.getUrlMappings().toString()).isEqualTo("[/]");
    assertThat(registration.getServletName()).isEqualTo("dispatcherServlet");
    assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length).isEqualTo(2);
}
Also used : DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.Test)

Aggregations

AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)244 Test (org.junit.Test)116 MockServletContext (org.springframework.mock.web.MockServletContext)75 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)42 ContextLoaderListener (org.springframework.web.context.ContextLoaderListener)30 MockMvc (org.springframework.test.web.servlet.MockMvc)26 ServletRegistration (javax.servlet.ServletRegistration)25 HashMap (java.util.HashMap)24 URI (java.net.URI)23 MapPropertySource (org.springframework.core.env.MapPropertySource)23 StandardEnvironment (org.springframework.core.env.StandardEnvironment)23 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)21 Test (org.junit.jupiter.api.Test)17 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