Package org.springframework.boot.context.embedded

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


    verifyContext();
  }

  @Test
  public void customizeContainerThroughCallback() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        CallbackEmbeddedContainerCustomizer.class, BaseConfiguration.class);
    verifyContext();
    assertEquals(9000, getContainerFactory().getPort());
  }
View Full Code Here


    }
  }

  @Test
  public void containerWithNothing() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        ContainerWithNothing.class, BaseConfiguration.class);
    DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
    assertNotNull(servlet.getMultipartResolver());
    assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class)
        .size(), equalTo(1));
View Full Code Here

  public static class ContainerWithNothing {
  }

  @Test
  public void containerWithNoMultipartJettyConfiguration() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        ContainerWithNoMultipartJetty.class, BaseConfiguration.class);
    DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
    assertNotNull(servlet.getMultipartResolver());
    assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class)
        .size(), equalTo(1));
View Full Code Here

    }
  }

  @Test
  public void containerWithNoMultipartTomcatConfiguration() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        ContainerWithNoMultipartTomcat.class, BaseConfiguration.class);
    DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
    assertNull(servlet.getMultipartResolver());
    assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class)
        .size(), equalTo(1));
View Full Code Here

    verifyServletWorks();
  }

  @Test
  public void containerWithAutomatedMultipartJettyConfiguration() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        ContainerWithEverythingJetty.class, BaseConfiguration.class);
    this.context.getBean(MultipartConfigElement.class);
    assertSame(this.context.getBean(DispatcherServlet.class).getMultipartResolver(),
        this.context.getBean(StandardServletMultipartResolver.class));
    verifyServletWorks();
View Full Code Here

    verifyServletWorks();
  }

  @Test
  public void containerWithAutomatedMultipartTomcatConfiguration() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        ContainerWithEverythingTomcat.class, BaseConfiguration.class);
    new RestTemplate().getForObject("http://localhost:"
        + this.context.getEmbeddedServletContainer().getPort() + "/",
        String.class);
    this.context.getBean(MultipartConfigElement.class);
View Full Code Here

  }

  @Test
  public void containerWithMultipartConfigDisabled() {

    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.getEnvironment().getPropertySources()
        .addFirst(new PropertySource<Object>("test") {
          @Override
          public Object getProperty(String name) {
            if (name.toLowerCase().contains("multipart.enabled")) {
View Full Code Here

    assertEquals(0, this.context.getBeansOfType(MultipartConfigElement.class).size());
  }

  @Test
  public void containerWithCustomMulipartResolver() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        ContainerWithCustomMultipartResolver.class, BaseConfiguration.class);
    MultipartResolver multipartResolver = this.context
        .getBean(MultipartResolver.class);
    assertThat(multipartResolver,
        not(instanceOf(StandardServletMultipartResolver.class)));
View Full Code Here

    }
  }

  @Test
  public void createFromConfigClass() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "server.port:9000");
    this.context.refresh();
    ServerProperties server = this.context.getBean(ServerProperties.class);
View Full Code Here

  }

  @Test
  public void tomcatProperties() throws Exception {
    containerFactory = mock(TomcatEmbeddedServletContainerFactory.class);
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Config.class, ServerPropertiesAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
        "server.tomcat.basedir:target/foo", "server.port:9000");
    this.context.refresh();
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.