Broadly remove deprecated core classes and methods

Issue: SPR-14430
This commit is contained in:
Juergen Hoeller
2016-07-05 15:52:48 +02:00
parent 0fc0ce78ae
commit b5db5d3aac
119 changed files with 145 additions and 6086 deletions

View File

@@ -43,12 +43,6 @@ public class DummyEnvironment implements Environment {
return null;
}
@Override
@Deprecated
public <T> Class<T> getPropertyAsClass(String key, Class<T> targetType) {
return null;
}
@Override
public String getRequiredProperty(String key) throws IllegalStateException {
return null;

View File

@@ -22,21 +22,21 @@ 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.*;
import static org.junit.Assert.*;
/**
* Unit tests for {@link AbstractPropertySource} implementations.
* Unit tests for {@link PropertySource} implementations.
*
* @author Chris Beams
* @since 3.1
*/
public class PropertySourceTests {
@Test @SuppressWarnings("serial")
@Test
@SuppressWarnings("serial")
public void equals() {
Map<String, Object> map1 = new HashMap<String, Object>() {{ put("a", "b"); }};
Map<String, Object> map2 = new HashMap<String, Object>() {{ put("c", "d"); }};
@@ -59,7 +59,8 @@ public class PropertySourceTests {
assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props2)), is(false));
}
@Test @SuppressWarnings("serial")
@Test
@SuppressWarnings("serial")
public void collectionsOperations() {
Map<String, Object> map1 = new HashMap<String, Object>() {{ put("a", "b"); }};
Map<String, Object> map2 = new HashMap<String, Object>() {{ put("c", "d"); }};
@@ -87,33 +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);
}
}
}

View File

@@ -23,7 +23,6 @@ import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.convert.ConversionException;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.mock.env.MockPropertySource;
@@ -257,78 +256,6 @@ public class PropertySourcesPropertyResolverTests {
new PropertySourcesPropertyResolver(new MutablePropertySources()).resolveRequiredPlaceholders(null);
}
@Test
@SuppressWarnings("deprecation")
public void getPropertyAsClass() throws ClassNotFoundException, LinkageError {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", SpecificType.class.getName()));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SpecificType.class));
}
@Test
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withInterfaceAsTarget() throws ClassNotFoundException, LinkageError {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", SomeType.class.getName()));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SomeType.class));
}
@Test(expected = ConversionException.class)
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withMismatchedTypeForValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", "java.lang.String"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
resolver.getPropertyAsClass("some.class", SomeType.class);
}
@Test(expected = ConversionException.class)
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withNonExistentClassForValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", "some.bogus.Class"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
resolver.getPropertyAsClass("some.class", SomeType.class);
}
@Test
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withObjectForValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", new SpecificType()));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SpecificType.class));
}
@Test(expected = ConversionException.class)
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withMismatchedObjectForValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", new Integer(42)));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
resolver.getPropertyAsClass("some.class", SomeType.class);
}
@Test
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withRealClassForValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", SpecificType.class));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SpecificType.class));
}
@Test(expected = ConversionException.class)
@SuppressWarnings("deprecation")
public void getPropertyAsClass_withMismatchedRealClassForValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("some.class", Integer.class));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
resolver.getPropertyAsClass("some.class", SomeType.class);
}
@Test
public void setRequiredProperties_andValidateRequiredProperties() {
// no properties have been marked as required -> validation should pass