Package org.springframework.boot

Examples of org.springframework.boot.SpringApplication


    context.close();
  }

  @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


    context.close();
  }

  @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

  @Test
  public void bindsToSpringApplication() throws Exception {
    // gh-346
    this.initializer.setSearchNames("bindtoapplication");
    this.initializer.onApplicationEvent(this.event);
    SpringApplication application = this.event.getSpringApplication();
    Field field = ReflectionUtils.findField(SpringApplication.class, "showBanner");
    field.setAccessible(true);
    assertThat((Boolean) field.get(application), equalTo(false));
  }
View Full Code Here

  @Test
  public void bindsSystemPropertyToSpringApplication() throws Exception {
    // gh-951
    System.setProperty("spring.main.showBanner", "false");
    this.initializer.onApplicationEvent(this.event);
    SpringApplication application = this.event.getSpringApplication();
    Field field = ReflectionUtils.findField(SpringApplication.class, "showBanner");
    field.setAccessible(true);
    assertThat((Boolean) field.get(application), equalTo(false));
  }
View Full Code Here

    AnsiOutput.setEnabled(Enabled.DETECT);
  }

  @Test
  public void enabled() {
    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));
  }
View Full Code Here

    assertThat(AnsiOutputEnabledValue.get(), equalTo(Enabled.ALWAYS));
  }

  @Test
  public void disabled() throws Exception {
    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));
  }
View Full Code Here

  @Test
  public void disabledViaApplcationProperties() throws Exception {
    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));
  }
View Full Code Here

      context.refresh();
      fail("Did not error");
    }
    catch (Exception ex) {
      this.initializer.onApplicationEvent(new ApplicationFailedEvent(
          new SpringApplication(), new String[0], context, ex));
    }

    assertThat(this.debugLog.size(), not(equalTo(0)));
    assertThat(this.infoLog.size(), equalTo(0));
  }
View Full Code Here

      context.refresh();
      fail("Did not error");
    }
    catch (Exception ex) {
      this.initializer.onApplicationEvent(new ApplicationFailedEvent(
          new SpringApplication(), new String[0], context, ex));
    }

    assertThat(this.debugLog.size(), equalTo(0));
    assertThat(this.infoLog.size(), not(equalTo(0)));
  }
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.