Consistent logging in Environment and PropertySource implementations
Issue: SPR-15825
(cherry picked from commit fac83b2)
This commit is contained in:
@@ -22,8 +22,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
@@ -90,34 +88,4 @@ public class PropertySourceTests {
|
||||
propertySources.clear();
|
||||
}
|
||||
|
||||
@Test @SuppressWarnings("serial")
|
||||
public void toString_verbosityVariesOnLogLevel() {
|
||||
String name = "props";
|
||||
Map<String, Object> map = new HashMap<String, Object>() {{ put("k1", "v1"); }};
|
||||
MapPropertySource ps = new MapPropertySource(name, map);
|
||||
Logger logger = Logger.getLogger(ps.getClass());
|
||||
Level original = logger.getLevel();
|
||||
|
||||
try {
|
||||
logger.setLevel(Level.DEBUG);
|
||||
assertThat("PropertySource.toString() should render verbose output for log levels <= DEBUG",
|
||||
ps.toString(),
|
||||
equalTo(String.format("%s@%s [name='%s', properties=%s]",
|
||||
ps.getClass().getSimpleName(),
|
||||
System.identityHashCode(ps),
|
||||
name,
|
||||
map)));
|
||||
|
||||
logger.setLevel(Level.INFO);
|
||||
assertThat("PropertySource.toString() should render concise output for log levels >= INFO",
|
||||
ps.toString(),
|
||||
equalTo(String.format("%s [name='%s']",
|
||||
ps.getClass().getSimpleName(),
|
||||
name)));
|
||||
}
|
||||
finally {
|
||||
logger.setLevel(original);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user