Examples of SpringApplication


Examples of org.springframework.boot.SpringApplication

  @Test
  public void emptyInitializers() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "context.listener.classes:");
    this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(
        new SpringApplication(), new String[0], this.context.getEnvironment()));
  }
View Full Code Here

Examples of org.springframework.boot.SpringApplication

  private static final String LINE_SEPARATOR = System.getProperty("line.separator");

  @Override
  public ApplicationContext loadContext(MergedContextConfiguration config)
      throws Exception {
    SpringApplication application = getSpringApplication();
    application.setSources(getSources(config));
    ConfigurableEnvironment environment = new StandardEnvironment();
    if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
      String profiles = StringUtils.arrayToCommaDelimitedString(config
          .getActiveProfiles());
      EnvironmentTestUtils.addEnvironment(environment, "spring.profiles.active="
          + profiles);
    }
    // Ensure @IntegrationTest properties go before external config and after system
    environment.getPropertySources()
        .addAfter(
            StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
            new MapPropertySource("integrationTest",
                getEnvironmentProperties(config)));
    application.setEnvironment(environment);
    List<ApplicationContextInitializer<?>> initializers = getInitializers(config,
        application);
    if (config instanceof WebMergedContextConfiguration) {
      new WebConfigurer().configure(config, application, initializers);
    }
    else {
      application.setWebEnvironment(false);
    }
    application.setInitializers(initializers);
    return application.run();
  }
View Full Code Here

Examples of org.springframework.boot.SpringApplication

   * Builds new {@link org.springframework.boot.SpringApplication} instance. You can
   * override this method to add custom behaviour
   * @return {@link org.springframework.boot.SpringApplication} instance
   */
  protected SpringApplication getSpringApplication() {
    return new SpringApplication();
  }
View Full Code Here

Examples of org.springframework.boot.SpringApplication

  @Before
  public void init() throws SecurityException, IOException {
    LogManager.getLogManager().readConfiguration(
        JavaLoggingSystem.class.getResourceAsStream("logging.properties"));
    this.initializer.onApplicationEvent(new ApplicationStartedEvent(
        new SpringApplication(), NO_ARGS));
    new File("target/foo.log").delete();
    new File(tmpDir() + "/spring.log").delete();
  }
View Full Code Here

Examples of org.springframework.boot.SpringApplication

        + location + "]"));
  }

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

Examples of org.springframework.boot.SpringApplication

  @Test
  public void propertySourceAnnotationWithPlaceholder() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.environment,
        "source.location:specificlocation");
    SpringApplication application = new SpringApplication(
        WithPropertySourcePlaceholders.class);
    application.setEnvironment(this.environment);
    application.setWebEnvironment(false);
    ConfigurableApplicationContext context = application.run();
    String property = context.getEnvironment().getProperty("the.property");
    assertThat(property, equalTo("fromspecificlocation"));
    assertThat(context.getEnvironment(),
        containsPropertySource("class path resource "
            + "[specificlocation.properties]"));
View Full Code Here

Examples of org.springframework.boot.SpringApplication

    context.close();
  }

  @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

Examples of org.springframework.boot.SpringApplication

    context.close();
  }

  @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

Examples of org.springframework.boot.SpringApplication

    context.close();
  }

  @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

Examples of org.springframework.boot.SpringApplication

    context.close();
  }

  @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
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.