Package org.springframework.boot.context.embedded

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


    }

    @Test
    public void mvcEndpoint() throws Throwable {

        AnnotationConfigEmbeddedWebApplicationContext applicationContext =
            new AnnotationConfigEmbeddedWebApplicationContext(CallbackEmbeddedContainerCustomizer.class, EmbeddedContainerConfiguration.class, EndpointConfiguration.class);

        ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
        org.junit.Assert.assertNotNull("the processEngine should not be null", processEngine);

        ProcessEngineEndpoint processEngineEndpoint =
                applicationContext.getBean(ProcessEngineEndpoint.class);
        org.junit.Assert.assertNotNull("the processEngineEndpoint should not be null", processEngineEndpoint);

        RestTemplate restTemplate = applicationContext.getBean(RestTemplate.class);

        ResponseEntity<Map> mapResponseEntity =
                restTemplate.getForEntity("http://localhost:9091/activiti/", Map.class);

        Map map = mapResponseEntity.getBody();
View Full Code Here


  private AnnotationConfigEmbeddedWebApplicationContext context;

  @Test
  public void testRestApiIntegration() throws Throwable {

    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(BaseConfiguration.class);
    this.context.refresh();
   
    RestTemplate restTemplate = this.context.getBean(RestTemplate.class) ;
View Full Code Here

    return new ShutdownMvcEndpoint(delegate);
  }

  private void createChildManagementContext() {

    final AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
    childContext.setParent(this.applicationContext);
    childContext.setNamespace("management");
    childContext.setId(this.applicationContext.getId() + ":management");

    // Register the ManagementServerChildContextConfiguration first followed
    // by various specific AutoConfiguration classes. NOTE: The child context
    // is intentionally not completely auto-configured.
    childContext.register(EndpointWebMvcChildContextConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class,
        EmbeddedServletContainerAutoConfiguration.class,
        DispatcherServletAutoConfiguration.class);

    // Ensure close on the parent also closes the child
    if (this.applicationContext instanceof ConfigurableApplicationContext) {
      ((ConfigurableApplicationContext) this.applicationContext)
          .addApplicationListener(new ApplicationListener<ContextClosedEvent>() {
            @Override
            public void onApplicationEvent(ContextClosedEvent event) {
              if (event.getApplicationContext() == EndpointWebMvcAutoConfiguration.this.applicationContext) {
                childContext.close();
              }
            }
          });
    }
    try {
      childContext.refresh();
    }
    catch (RuntimeException ex) {
      // No support currently for deploying a war with management.port=<different>,
      // and this is the signature of that happening
      if (ex instanceof EmbeddedServletContainerException
View Full Code Here

  private AnnotationConfigEmbeddedWebApplicationContext context;

  @Test
  public void createFromConfigClass() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        BaseConfiguration.class);
    verifyContext();
  }
View Full Code Here

    verifyContext();
  }

  @Test
  public void contextAlreadyHasDispatcherServletWithDefaultName() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        DispatcherServletConfiguration.class, BaseConfiguration.class);
    verifyContext();
  }
View Full Code Here

    verifyContext();
  }

  @Test
  public void contextAlreadyHasDispatcherServlet() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        SpringServletConfiguration.class, BaseConfiguration.class);
    verifyContext();
    assertEquals(2, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }
View Full Code Here

    assertEquals(2, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }

  @Test
  public void contextAlreadyHasNonDispatcherServlet() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        NonSpringServletConfiguration.class, BaseConfiguration.class);
    verifyContext(); // the non default servlet is still registered
    assertEquals(0, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }
View Full Code Here

    assertEquals(0, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }

  @Test
  public void contextAlreadyHasNonServlet() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        NonServletConfiguration.class, BaseConfiguration.class);
    assertEquals(0, this.context.getBeanNamesForType(DispatcherServlet.class).length);
    assertEquals(0, this.context.getBeanNamesForType(Servlet.class).length);
  }
View Full Code Here

    assertEquals(0, this.context.getBeanNamesForType(Servlet.class).length);
  }

  @Test
  public void contextAlreadyHasDispatcherServletAndRegistration() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        DispatcherServletWithRegistrationConfiguration.class,
        BaseConfiguration.class);
    verifyContext();
    assertEquals(1, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }
View Full Code Here

    assertEquals(1, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }

  @Test
  public void containerHasNoServletContext() throws Exception {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext(
        EnsureContainerHasNoServletContext.class, BaseConfiguration.class);
    verifyContext();
  }
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.