Introduce MockEnvironment in the spring-test module

For legacy reasons, a MockEnvironment implementation already exists in multiple places within Spring's test suite; however, it is not available to the general public.

This commit promotes MockEnvironment to a first-class citizen in the spring-test module, alongside the existing MockPropertySource.

In addition, the following house cleaning has been performed.

 - deleted MockPropertySource from the spring-expression module
 - deleted MockEnvironment from the "spring" integration testing module
 - updated test copies of MockPropertySource and MockEnvironment
 - documented MockEnvironment and MockPropertySource in the testing
   chapter of the reference manual

Issue: SPR-9492
This commit is contained in:
Sam Brannen
2012-07-28 20:10:21 +02:00
parent 0329df218e
commit f49b22c78f
9 changed files with 72 additions and 143 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,13 +20,14 @@ import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.ConfigurableEnvironment;
/**
* Simple {@link ConfigurableEnvironment} implementation exposing a
* Simple {@link ConfigurableEnvironment} implementation exposing
* {@link #setProperty(String, String)} and {@link #withProperty(String, String)}
* methods for testing purposes.
*
* @author Chris Beams
* @since 3.1
* @see MockPropertySource
* @author Sam Brannen
* @since 3.2
* @see org.springframework.mock.env.MockPropertySource
*/
public class MockEnvironment extends AbstractEnvironment {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import org.springframework.core.env.PropertySource;
*
* @author Chris Beams
* @since 3.1
* @see MockEnvironment
* @see org.springframework.mock.env.MockEnvironment
*/
public class MockPropertySource extends PropertiesPropertySource {
@@ -75,7 +75,7 @@ public class MockPropertySource extends PropertiesPropertySource {
}
/**
* Create a new {@code MockPropertySource} with with the given name and backed by the given
* Create a new {@code MockPropertySource} with the given name and backed by the given
* {@link Properties} object
* @param name the {@linkplain #getName() name} of the property source
* @param properties the properties to use
@@ -100,4 +100,5 @@ public class MockPropertySource extends PropertiesPropertySource {
this.setProperty(name, value);
return this;
}
}