Package org.springframework.boot

Examples of org.springframework.boot.SpringApplication.run()


  @Test
  public void propertySourceAnnotationWithName() throws Exception {
    SpringApplication application = new SpringApplication(
        WithPropertySourceAndName.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application.run();
    String property = context.getEnvironment().getProperty("the.property");
    assertThat(property, equalTo("fromspecificlocation"));
    assertThat(context.getEnvironment(), containsPropertySource("foo"));
    context.close();
  }
View Full Code Here


  @Test
  public void propertySourceAnnotationInProfile() throws Exception {
    SpringApplication application = new SpringApplication(
        WithPropertySourceInProfile.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application
        .run("--spring.profiles.active=myprofile");
    String property = context.getEnvironment().getProperty("the.property");
    assertThat(property, equalTo("frompropertiesfile"));
    assertThat(context.getEnvironment(),
        containsPropertySource("class path resource "
View Full Code Here

  @Test
  public void propertySourceAnnotationAndNonActiveProfile() throws Exception {
    SpringApplication application = new SpringApplication(
        WithPropertySourceAndProfile.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application.run();
    String property = context.getEnvironment().getProperty("my.property");
    assertThat(property, equalTo("fromapplicationproperties"));
    assertThat(context.getEnvironment(), not(containsPropertySource("classpath:"
        + "/enableprofile-myprofile.properties")));
    context.close();
View Full Code Here

  @Test
  public void propertySourceAnnotationMultipleLocations() throws Exception {
    SpringApplication application = new SpringApplication(
        WithPropertySourceMultipleLocations.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application.run();
    String property = context.getEnvironment().getProperty("the.property");
    assertThat(property, equalTo("frommorepropertiesfile"));
    assertThat(context.getEnvironment(),
        containsPropertySource("class path resource "
            + "[specificlocation.properties]"));
View Full Code Here

  @Test
  public void propertySourceAnnotationMultipleLocationsAndName() throws Exception {
    SpringApplication application = new SpringApplication(
        WithPropertySourceMultipleLocationsAndName.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application.run();
    String property = context.getEnvironment().getProperty("the.property");
    assertThat(property, equalTo("frommorepropertiesfile"));
    assertThat(context.getEnvironment(), containsPropertySource("foo"));
    context.close();
  }
View Full Code Here

  @Test
  public void activateProfileFromProfileSpecificProperties() throws Exception {
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application
        .run("--spring.profiles.active=includeprofile");
    assertThat(context.getEnvironment(), acceptsProfiles("includeprofile"));
    assertThat(context.getEnvironment(), acceptsProfiles("specific"));
    assertThat(context.getEnvironment(), acceptsProfiles("morespecific"));
    assertThat(context.getEnvironment(), acceptsProfiles("yetmorespecific"));
View Full Code Here

  @Test
  public void profileSubDocumentInProfileSpecificFile() throws Exception {
    // gh-340
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application
        .run("--spring.profiles.active=activeprofilewithsubdoc");
    String property = context.getEnvironment().getProperty("foobar");
    assertThat(property, equalTo("baz"));
  }
View Full Code Here

    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "ALWAYS");
    application.setDefaultProperties(props);
    application.run();
    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.ALWAYS));
  }

  @Test
  public void disabled() throws Exception {
View Full Code Here

    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put("spring.output.ansi.enabled", "never");
    application.setDefaultProperties(props);
    application.run();
    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.NEVER));
  }

  @Test
  public void disabledViaApplcationProperties() throws Exception {
View Full Code Here

    ConfigurableEnvironment environment = new StandardEnvironment();
    EnvironmentTestUtils.addEnvironment(environment, "spring.config.name:ansi");
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebEnvironment(false);
    application.setEnvironment(environment);
    application.run();
    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.NEVER));
  }

  @Configuration
  public static class Config {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.