Package org.springframework.boot.context.embedded

Examples of org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext


    this.context.getBean(LocaleResolver.class);
  }

  @Test
  public void overrideLocale() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    // set fixed locale
    EnvironmentTestUtils.addEnvironment(this.context, "spring.mvc.locale:en_UK");
    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
View Full Code Here


    assertThat(locale.toString(), equalTo("en_UK"));
  }

  @Test
  public void noDateFormat() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
View Full Code Here

    assertThat(cs.convert(date, String.class), equalTo(date.toString()));
  }

  @Test
  public void overrideDateFormat() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    // set fixed date format
    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.mvc.dateFormat:dd*MM*yyyy");
    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
View Full Code Here

    assertThat(cs.convert(date, String.class), equalTo("25*06*1988"));
  }

  @Test
  public void noMessageCodesResolver() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
View Full Code Here

        .getMessageCodesResolver());
  }

  @Test
  public void overrideMessageCodesFormat() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.mvc.messageCodesResolverFormat:POSTFIX_ERROR_CODE");
    this.context.register(AllResources.class, Config.class,
        WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void deviceResolverHandlerInterceptorRegistered() throws Exception {
    AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
    context.register(Config.class, WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        DeviceResolverAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    context.refresh();
    RequestMappingHandlerMapping mapping = (RequestMappingHandlerMapping) context
        .getBean("requestMappingHandlerMapping");
    Field interceptorsField = ReflectionUtils.findField(
        RequestMappingHandlerMapping.class, "interceptors");
    interceptorsField.setAccessible(true);
    List<Object> interceptors = (List<Object>) ReflectionUtils.getField(
        interceptorsField, mapping);
    context.close();
    for (Object o : interceptors) {
      if (o instanceof DeviceResolverHandlerInterceptor) {
        return;
      }
    }
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void sitePreferenceHandlerInterceptorRegistered() throws Exception {
    AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
    context.register(Config.class, WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        SitePreferenceAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    context.refresh();
    RequestMappingHandlerMapping mapping = (RequestMappingHandlerMapping) context
        .getBean("requestMappingHandlerMapping");
    Field interceptorsField = ReflectionUtils.findField(
        RequestMappingHandlerMapping.class, "interceptors");
    interceptorsField.setAccessible(true);
    List<Object> interceptors = (List<Object>) ReflectionUtils.getField(
        interceptorsField, mapping);
    context.close();
    for (Object o : interceptors) {
      if (o instanceof SitePreferenceHandlerInterceptor) {
        return;
      }
    }
View Full Code Here

    }
  }

  @Test(expected = NoSuchBeanDefinitionException.class)
  public void deviceDelegatingViewResolverDefaultDisabled() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Config.class,
        DeviceDelegatingViewResolverConfiguration.class);
    this.context.refresh();
    this.context.getBean("deviceDelegatingViewResolver",
        AbstractDeviceDelegatingViewResolver.class);
View Full Code Here

        AbstractDeviceDelegatingViewResolver.class);
  }

  @Test
  public void deviceDelegatingInternalResourceViewResolverEnabled() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.mobile.devicedelegatingviewresolver.enabled:true");
    this.context.register(Config.class, WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class,
View Full Code Here

        .getOrder() - 1);
  }

  @Test(expected = NoSuchBeanDefinitionException.class)
  public void deviceDelegatingInternalResourceViewResolverDisabled() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context,
        "spring.mobile.devicedelegatingviewresolver.enabled:false");
    this.context.register(Config.class, WebMvcAutoConfiguration.class,
        HttpMessageConvertersAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class,
View Full Code Here

TOP

Related Classes of org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.