Package org.springframework.mock.env

Examples of org.springframework.mock.env.MockPropertySource


  }

  @Test
  public void acceptsProfiles_activeProfileSetViaProperty() {
    assertThat(environment.acceptsProfiles("p1"), is(false));
    environment.getPropertySources().addFirst(new MockPropertySource().withProperty(ACTIVE_PROFILES_PROPERTY_NAME, "p1"));
    assertThat(environment.acceptsProfiles("p1"), is(true));
  }
View Full Code Here


      ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
      applicationContext.getEnvironment().getPropertySources().addFirst(
        new MockPropertySource().withProperty("enigma", "foo"));
    }
View Full Code Here

public class PropertyMockingApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @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

  @Test
  public void overridePidFileWithSpring() throws Exception {
    File file = this.temporaryFolder.newFile();
    ConfigurableEnvironment environment = new StandardEnvironment();
    MockPropertySource propertySource = new MockPropertySource();
    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);
View Full Code Here

  @Test
  public void differentEventTypes() throws Exception {
    File file = this.temporaryFolder.newFile();
    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);
View Full Code Here

  private static final String CONFIGURATIONS_BASE_PACKAGE = "org.lightadmin.core.test.config";

  @Override
  protected void customizeContext( final GenericApplicationContext context ) {
    MockPropertySource mockPropertySource = new MockPropertySource();
    mockPropertySource.setProperty( LightAdminConfigurationUtils.LIGHT_ADMINISTRATION_BASE_PACKAGE, CONFIGURATIONS_BASE_PACKAGE );
    context.getEnvironment().getPropertySources().addFirst( mockPropertySource );
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.env.MockPropertySource

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.