Package org.springframework.boot

Examples of org.springframework.boot.SpringApplication


  }

  @Test
  public void noErrorIfNotInitialized() throws Exception {
    this.initializer.onApplicationEvent(new ApplicationFailedEvent(
        new SpringApplication(), new String[0], null, new RuntimeException(
            "Planned")));
    assertThat(this.infoLog.get(0),
        containsString("Unable to provide auto-configuration report"));
  }
View Full Code Here


    }
  }

  @Test
  public void doesNotEarlyInitializeFactoryBeans() throws Exception {
    SpringApplication application = new SpringApplication(EarlyInitConfig.class,
        PropertySourcesPlaceholderConfigurer.class,
        EmbeddedServletContainerAutoConfiguration.class,
        ServerPropertiesAutoConfiguration.class);
    this.context = application.run("--server.port=0");
    String bean = (String) this.context.getBean("earlyInit");
    assertThat(bean, equalTo("bucket"));
  }
View Full Code Here

    assertTrue("Wrong content: " + content, content.contains("status=999"));
  }

  @Test
  public void errorPageAvailableWithMvcIncluded() throws Exception {
    setup((ConfigurableWebApplicationContext) new SpringApplication(
        WebMvcIncludedConfiguration.class).run("--server.port=0"));
    MvcResult response = this.mockMvc
        .perform(get("/error").accept(MediaType.TEXT_HTML))
        .andExpect(status().isOk()).andReturn();
    String content = response.getResponse().getContentAsString();
View Full Code Here

    assertTrue("Wrong content: " + content, content.contains("status=999"));
  }

  @Test
  public void errorPageNotAvailableWithWhitelabelDisabled() throws Exception {
    setup((ConfigurableWebApplicationContext) new SpringApplication(
        WebMvcIncludedConfiguration.class).run("--server.port=0", "--error.whitelabel.enabled=false"));

    thrown.expect(ServletException.class);
    this.mockMvc.perform(get("/error").accept(MediaType.TEXT_HTML));
  }
View Full Code Here

    propertySource.setProperty("spring.pidfile", file.getAbsolutePath());
    environment.getPropertySources().addLast(propertySource);
    ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
    given(context.getEnvironment()).willReturn(environment);
    ApplicationPreparedEvent event = new ApplicationPreparedEvent(
        new SpringApplication(), new String[] {}, context);
    ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
    listener.onApplicationEvent(event);
    assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString()));
  }
View Full Code Here

    ConfigurableEnvironment environment = new StandardEnvironment();
    MockPropertySource propertySource = new MockPropertySource();
    propertySource.setProperty("spring.pidfile", file.getAbsolutePath());
    environment.getPropertySources().addLast(propertySource);
    ApplicationEnvironmentPreparedEvent event = new ApplicationEnvironmentPreparedEvent(
        new SpringApplication(), new String[] {}, environment);
    ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
    listener.onApplicationEvent(event);
    assertThat(FileCopyUtils.copyToString(new FileReader(file)), isEmptyString());
    listener.setTriggerEventType(ApplicationEnvironmentPreparedEvent.class);
    listener.onApplicationEvent(event);
View Full Code Here

  @Test
  public void withNoEnvironment() throws Exception {
    File file = this.temporaryFolder.newFile();
    ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
    listener.setTriggerEventType(ApplicationStartedEvent.class);
    listener.onApplicationEvent(new ApplicationStartedEvent(new SpringApplication(),
        new String[] {}));
    assertThat(FileCopyUtils.copyToString(new FileReader(file)), not(isEmptyString()));
  }
View Full Code Here

  }

  public static void main(String[] args) {
    // Main entry point
    printLogo();
    SpringApplication app = new SpringApplication(Para.class);
    app.setWebEnvironment(true);
    app.setShowBanner(false);
    initialize();
    app.run(args);
  }
View Full Code Here

@EnableAutoConfiguration
@Configuration
public class SampleSpringBootService {

    public static void main(String[] args) {
        new SpringApplication(SampleSpringBootService.class).run();
    }
View Full Code Here

TOP

Related Classes of org.springframework.boot.SpringApplication

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.