Java 类org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void contextPath() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "management.contextPath:/test");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    assertContent("/test/endpoint", ports.get().server, "endpointoutput");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void overrideServerProperties() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "server.displayName:foo");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    ServerProperties serverProperties = this.applicationContext
            .getBean(ServerProperties.class);
    assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ManagementWebSecurityAutoConfigurationTests.java   
@Test
public void testWebConfiguration() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(SecurityAutoConfiguration.class,
            WebMvcAutoConfiguration.class,
            ManagementWebSecurityAutoConfiguration.class,
            JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
    this.context.refresh();
    assertThat(this.context.getBean(AuthenticationManagerBuilder.class)).isNotNull();
    FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
    // 1 for static resources, one for management endpoints and one for the rest
    assertThat(filterChainProxy.getFilterChains()).hasSize(3);
    assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
    assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
    assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
    assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void contextPath() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "management.contextPath:/test");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    assertContent("/test/endpoint", ports.get().server, "endpointoutput");
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void overrideServerProperties() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "server.displayName:foo");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    ServerProperties serverProperties = this.applicationContext
            .getBean(ServerProperties.class);
    assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
项目:spring-boot-concourse    文件:ManagementWebSecurityAutoConfigurationTests.java   
@Test
public void testWebConfiguration() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(SecurityAutoConfiguration.class,
            WebMvcAutoConfiguration.class,
            ManagementWebSecurityAutoConfiguration.class,
            JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
    this.context.refresh();
    assertThat(this.context.getBean(AuthenticationManagerBuilder.class)).isNotNull();
    FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
    // 1 for static resources, one for management endpoints and one for the rest
    assertThat(filterChainProxy.getFilterChains()).hasSize(3);
    assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
    assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
    assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
    assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void contextPath() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "management.contextPath:/test");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    assertContent("/test/endpoint", ports.get().server, "endpointoutput");
    this.applicationContext.close();
    assertAllClosed();
}
项目:contestparser    文件:ManagementWebSecurityAutoConfigurationTests.java   
@Test
public void testWebConfiguration() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(SecurityAutoConfiguration.class,
            WebMvcAutoConfiguration.class,
            ManagementWebSecurityAutoConfiguration.class,
            JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "security.basic.enabled:false");
    this.context.refresh();
    assertNotNull(this.context.getBean(AuthenticationManagerBuilder.class));
    FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
    // 4 for static resources, one for management endpoints and one for the rest
    assertThat(filterChainProxy.getFilterChains(), hasSize(6));
    assertThat(filterChainProxy.getFilters("/beans"), hasSize(greaterThan(0)));
    assertThat(filterChainProxy.getFilters("/beans/"), hasSize(greaterThan(0)));
    assertThat(filterChainProxy.getFilters("/beans.foo"), hasSize(greaterThan(0)));
    assertThat(filterChainProxy.getFilters("/beans/foo/bar"),
            hasSize(greaterThan(0)));
}
项目:quickfixj-spring-boot-starter    文件:AbstractEndpointTests.java   
@Before
    public void setup() {
        this.context = new AnnotationConfigApplicationContext();
        this.context.register(JacksonAutoConfiguration.class, this.configClass);
        this.context.getEnvironment().getSystemProperties().putAll(systemProperties);
//        this.context.refresh();
    }
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ManagementWebSecurityAutoConfigurationTests.java   
@Test
public void realmSameForManagement() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(AuthenticationConfig.class, SecurityAutoConfiguration.class,
            ManagementWebSecurityAutoConfiguration.class,
            JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            WebMvcAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();

    Filter filter = this.context.getBean("springSecurityFilterChain", Filter.class);
    MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
            .addFilters(filter).build();

    // no user (Main)
    mockMvc.perform(MockMvcRequestBuilders.get("/home"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // invalid user (Main)
    mockMvc.perform(
            MockMvcRequestBuilders.get("/home").header("authorization", "Basic xxx"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // no user (Management)
    mockMvc.perform(MockMvcRequestBuilders.get("/beans"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // invalid user (Management)
    mockMvc.perform(
            MockMvcRequestBuilders.get("/beans").header("authorization", "Basic xxx"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MvcEndpointCorsIntegrationTests.java   
@Before
public void createContext() {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            JolokiaAutoConfiguration.class, WebMvcAutoConfiguration.class);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpMessageConvertersAutoConfigurationTests.java   
@Test
public void jacksonIsPreferredByDefaultWhenBothGsonAndJacksonAreAvailable() {
    this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class);
    this.context.refresh();
    assertConverterBeanExists(MappingJackson2HttpMessageConverter.class,
            "mappingJackson2HttpMessageConverter");
    assertConverterBeanRegisteredWithHttpMessageConverters(
            MappingJackson2HttpMessageConverter.class);
    assertThat(this.context.getBeansOfType(GsonHttpMessageConverter.class)).isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpMessageConvertersAutoConfigurationTests.java   
@Test
public void gsonCanBePreferredWhenBothGsonAndJacksonAreAvailable() {
    this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.http.converters.preferred-json-mapper:gson");
    this.context.refresh();
    assertConverterBeanExists(GsonHttpMessageConverter.class,
            "gsonHttpMessageConverter");
    assertConverterBeanRegisteredWithHttpMessageConverters(
            GsonHttpMessageConverter.class);
    assertThat(this.context.getBeansOfType(MappingJackson2HttpMessageConverter.class))
            .isEmpty();
}
项目:spring-boot-concourse    文件:ManagementWebSecurityAutoConfigurationTests.java   
@Test
public void realmSameForManagement() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(AuthenticationConfig.class, SecurityAutoConfiguration.class,
            ManagementWebSecurityAutoConfiguration.class,
            JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            WebMvcAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();

    Filter filter = this.context.getBean("springSecurityFilterChain", Filter.class);
    MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
            .addFilters(filter).build();

    // no user (Main)
    mockMvc.perform(MockMvcRequestBuilders.get("/home"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // invalid user (Main)
    mockMvc.perform(
            MockMvcRequestBuilders.get("/home").header("authorization", "Basic xxx"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // no user (Management)
    mockMvc.perform(MockMvcRequestBuilders.get("/beans"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // invalid user (Management)
    mockMvc.perform(
            MockMvcRequestBuilders.get("/beans").header("authorization", "Basic xxx"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());
}
项目:spring-boot-concourse    文件:MvcEndpointCorsIntegrationTests.java   
@Before
public void createContext() {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            JolokiaAutoConfiguration.class, WebMvcAutoConfiguration.class);
}
项目:spring-boot-concourse    文件:HttpMessageConvertersAutoConfigurationTests.java   
@Test
public void jacksonIsPreferredByDefaultWhenBothGsonAndJacksonAreAvailable() {
    this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class);
    this.context.refresh();
    assertConverterBeanExists(MappingJackson2HttpMessageConverter.class,
            "mappingJackson2HttpMessageConverter");
    assertConverterBeanRegisteredWithHttpMessageConverters(
            MappingJackson2HttpMessageConverter.class);
    assertThat(this.context.getBeansOfType(GsonHttpMessageConverter.class)).isEmpty();
}
项目:spring-boot-concourse    文件:HttpMessageConvertersAutoConfigurationTests.java   
@Test
public void gsonCanBePreferredWhenBothGsonAndJacksonAreAvailable() {
    this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.http.converters.preferred-json-mapper:gson");
    this.context.refresh();
    assertConverterBeanExists(GsonHttpMessageConverter.class,
            "gsonHttpMessageConverter");
    assertConverterBeanRegisteredWithHttpMessageConverters(
            GsonHttpMessageConverter.class);
    assertThat(this.context.getBeansOfType(MappingJackson2HttpMessageConverter.class))
            .isEmpty();
}
项目:contestparser    文件:ManagementWebSecurityAutoConfigurationTests.java   
@Test
public void realmSameForManagement() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(AuthenticationConfig.class, SecurityAutoConfiguration.class,
            ManagementWebSecurityAutoConfiguration.class,
            JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            WebMvcAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();

    Filter filter = this.context.getBean("springSecurityFilterChain", Filter.class);
    MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
            .addFilters(filter).build();

    // no user (Main)
    mockMvc.perform(MockMvcRequestBuilders.get("/home"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // invalid user (Main)
    mockMvc.perform(
            MockMvcRequestBuilders.get("/home").header("authorization", "Basic xxx"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // no user (Management)
    mockMvc.perform(MockMvcRequestBuilders.get("/beans"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());

    // invalid user (Management)
    mockMvc.perform(
            MockMvcRequestBuilders.get("/beans").header("authorization", "Basic xxx"))
            .andExpect(MockMvcResultMatchers.status().isUnauthorized())
            .andExpect(springAuthenticateRealmHeader());
}
项目:contestparser    文件:MvcEndpointCorsIntegrationTests.java   
@Before
public void createContext() {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            EndpointAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            JolokiaAutoConfiguration.class, WebMvcAutoConfiguration.class);
}
项目:contestparser    文件:HttpMessageConvertersAutoConfigurationTests.java   
@Test
public void jacksonIsPreferredByDefaultWhenBothGsonAndJacksonAreAvailable() {
    this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class);
    this.context.refresh();
    assertConverterBeanExists(MappingJackson2HttpMessageConverter.class,
            "mappingJackson2HttpMessageConverter");
    assertConverterBeanRegisteredWithHttpMessageConverters(
            MappingJackson2HttpMessageConverter.class);
    assertEquals(0,
            this.context.getBeansOfType(GsonHttpMessageConverter.class).size());
}
项目:contestparser    文件:HttpMessageConvertersAutoConfigurationTests.java   
@Test
public void gsonCanBePreferredWhenBothGsonAndJacksonAreAvailable() {
    this.context.register(GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "spring.http.converters.preferred-json-mapper:gson");
    this.context.refresh();
    assertConverterBeanExists(GsonHttpMessageConverter.class,
            "gsonHttpMessageConverter");
    assertConverterBeanRegisteredWithHttpMessageConverters(
            GsonHttpMessageConverter.class);
    assertEquals(0, this.context
            .getBeansOfType(MappingJackson2HttpMessageConverter.class).size());
}
项目:spring-cloud-commons    文件:FeaturesEndpointTests.java   
@Before
public void setup() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JacksonAutoConfiguration.class, FeaturesConfig.class,
            Config.class);
    this.context.refresh();
}
项目:initializr    文件:InitializrAutoConfigurationTests.java   
private void load(Class<?> config, String... environment) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(ctx, environment);
    if (config != null) {
        ctx.register(config);
    }
    ctx.register(WebClientAutoConfiguration.class, JacksonAutoConfiguration.class,
            InitializrAutoConfiguration.class);
    ctx.refresh();
    this.context = ctx;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractEndpointTests.java   
@Before
public void setup() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JacksonAutoConfiguration.class, this.configClass);
    this.context.refresh();
}
项目:spring-boot-concourse    文件:AbstractEndpointTests.java   
@Before
public void setup() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JacksonAutoConfiguration.class, this.configClass);
    this.context.refresh();
}
项目:contestparser    文件:AbstractEndpointTests.java   
@Before
public void setup() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JacksonAutoConfiguration.class, this.configClass);
    this.context.refresh();
}