Package org.springframework.core.env

Examples of org.springframework.core.env.MutablePropertySources.replace()


    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();
        MockPropertySource mockEnvVars = new MockPropertySource().withProperty("bookService.port", PortFactory.findFreePort());
        propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
    }
}
View Full Code Here


          existing = ((ResourcePropertySource) existing).withResourceName();
        }
        CompositePropertySource composite = new CompositePropertySource(name);
        composite.addPropertySource(propertySource.withResourceName());
        composite.addPropertySource(existing);
        propertySources.replace(name, composite);
      }
    }
    else {
      if (this.propertySourceNames.isEmpty()) {
        propertySources.addLast(propertySource);
View Full Code Here

    assertThat(sources.size(), equalTo(7));
    assertThat(sources.precedenceOf(PropertySource.named("a")), is(0));
    assertThat(sources.precedenceOf(PropertySource.named("b")), is(1));
    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));

    sources.replace("a", new MockPropertySource("a-replaced"));
    assertThat(sources.size(), equalTo(7));
    assertThat(sources.precedenceOf(PropertySource.named("a-replaced")), is(0));
    assertThat(sources.precedenceOf(PropertySource.named("b")), is(1));
    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));
View Full Code Here

    assertThat(sources.size(), equalTo(7));
    assertThat(sources.precedenceOf(PropertySource.named("a-replaced")), is(0));
    assertThat(sources.precedenceOf(PropertySource.named("b")), is(1));
    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));

    sources.replace("a-replaced", new MockPropertySource("a"));

    try {
      sources.replace(bogusPS, new MockPropertySource("bogus-replaced"));
      fail("expected non-existent PropertySource exception");
    } catch (IllegalArgumentException ex) {
View Full Code Here

    assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));

    sources.replace("a-replaced", new MockPropertySource("a"));

    try {
      sources.replace(bogusPS, new MockPropertySource("bogus-replaced"));
      fail("expected non-existent PropertySource exception");
    } catch (IllegalArgumentException ex) {
      assertThat(ex.getMessage(),
          equalTo(format(NON_EXISTENT_PROPERTY_SOURCE_MESSAGE, bogusPS)));
    }
View Full Code Here

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();
        MockPropertySource mockEnvVars = new MockPropertySource().withProperty("bundling.enabled", false);
        propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
    }
}
View Full Code Here

        PropertySource<?> source = sources.get(name);
        CompositePropertySource composite = new CompositePropertySource(name);
        composite.addPropertySource(new SimpleCommandLinePropertySource(name
            + "-" + args.hashCode(), args));
        composite.addPropertySource(source);
        sources.replace(name, composite);
      }
      else {
        sources.addFirst(new SimpleCommandLinePropertySource(args));
      }
    }
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.