Deprecated getPropertyAsClass and refined PropertySourcesPropertyResolver's logging
Issue: SPR-14370
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -44,6 +44,7 @@ public class DummyEnvironment implements Environment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <T> Class<T> getPropertyAsClass(String key, Class<T> targetType) {
|
||||
return null;
|
||||
}
|
||||
@@ -54,8 +55,7 @@ public class DummyEnvironment implements Environment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getRequiredProperty(String key, Class<T> targetType)
|
||||
throws IllegalStateException {
|
||||
public <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,7 @@ public class DummyEnvironment implements Environment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveRequiredPlaceholders(String text)
|
||||
throws IllegalArgumentException {
|
||||
public String resolveRequiredPlaceholders(String text) throws IllegalArgumentException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ 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;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
@@ -114,9 +115,9 @@ public class PropertySourcesPropertyResolverTests {
|
||||
|
||||
try {
|
||||
propertyResolver.getProperty("foo", TestType.class);
|
||||
fail("Expected IllegalArgumentException due to non-convertible types");
|
||||
fail("Expected ConverterNotFoundException due to non-convertible types");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
catch (ConverterNotFoundException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
@@ -272,7 +273,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SomeType.class));
|
||||
}
|
||||
|
||||
@Test(expected=ConversionException.class)
|
||||
@Test(expected = ConversionException.class)
|
||||
public void getPropertyAsClass_withMismatchedTypeForValue() {
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addFirst(new MockPropertySource().withProperty("some.class", "java.lang.String"));
|
||||
@@ -280,7 +281,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
resolver.getPropertyAsClass("some.class", SomeType.class);
|
||||
}
|
||||
|
||||
@Test(expected=ConversionException.class)
|
||||
@Test(expected = ConversionException.class)
|
||||
public void getPropertyAsClass_withNonExistentClassForValue() {
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addFirst(new MockPropertySource().withProperty("some.class", "some.bogus.Class"));
|
||||
@@ -296,7 +297,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SpecificType.class));
|
||||
}
|
||||
|
||||
@Test(expected=ConversionException.class)
|
||||
@Test(expected = ConversionException.class)
|
||||
public void getPropertyAsClass_withMismatchedObjectForValue() {
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addFirst(new MockPropertySource().withProperty("some.class", new Integer(42)));
|
||||
@@ -312,7 +313,7 @@ public class PropertySourcesPropertyResolverTests {
|
||||
assertTrue(resolver.getPropertyAsClass("some.class", SomeType.class).equals(SpecificType.class));
|
||||
}
|
||||
|
||||
@Test(expected=ConversionException.class)
|
||||
@Test(expected = ConversionException.class)
|
||||
public void getPropertyAsClass_withMismatchedRealClassForValue() {
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addFirst(new MockPropertySource().withProperty("some.class", Integer.class));
|
||||
|
||||
Reference in New Issue
Block a user