Merge branch '5.1.x'

This commit is contained in:
Juergen Hoeller
2019-05-20 22:27:37 +02:00
5 changed files with 41 additions and 25 deletions

View File

@@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue;
public class ResourceEditorTests {
@Test
public void sunnyDay() throws Exception {
public void sunnyDay() {
PropertyEditor editor = new ResourceEditor();
editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class");
Resource resource = (Resource) editor.getValue();
@@ -46,20 +46,20 @@ public class ResourceEditorTests {
}
@Test
public void ctorWithNullCtorArgs() throws Exception {
public void ctorWithNullCtorArgs() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ResourceEditor(null, null));
}
@Test
public void setAndGetAsTextWithNull() throws Exception {
public void setAndGetAsTextWithNull() {
PropertyEditor editor = new ResourceEditor();
editor.setAsText(null);
assertEquals("", editor.getAsText());
}
@Test
public void setAndGetAsTextWithWhitespaceResource() throws Exception {
public void setAndGetAsTextWithWhitespaceResource() {
PropertyEditor editor = new ResourceEditor();
editor.setAsText(" ");
assertEquals("", editor.getAsText());
@@ -67,6 +67,20 @@ public class ResourceEditorTests {
@Test
public void testSystemPropertyReplacement() {
PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}");
Resource resolved = (Resource) editor.getValue();
assertEquals("foo", resolved.getFilename());
}
finally {
System.getProperties().remove("test.prop");
}
}
@Test
public void testSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo");
try {
@@ -80,7 +94,7 @@ public class ResourceEditorTests {
}
@Test
public void testStrictSystemPropertyReplacement() {
public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false);
System.setProperty("test.prop", "foo");
try {

View File

@@ -35,7 +35,7 @@ import static org.junit.Assert.assertTrue;
public class ResourceArrayPropertyEditorTests {
@Test
public void testVanillaResource() throws Exception {
public void testVanillaResource() {
PropertyEditor editor = new ResourceArrayPropertyEditor();
editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class");
Resource[] resources = (Resource[]) editor.getValue();
@@ -44,7 +44,7 @@ public class ResourceArrayPropertyEditorTests {
}
@Test
public void testPatternResource() throws Exception {
public void testPatternResource() {
// N.B. this will sometimes fail if you use classpath: instead of classpath*:.
// The result depends on the classpath - if test-classes are segregated from classes
// and they come first on the classpath (like in Maven) then it breaks, if classes
@@ -61,9 +61,9 @@ public class ResourceArrayPropertyEditorTests {
PropertyEditor editor = new ResourceArrayPropertyEditor();
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}-${bar}");
editor.setAsText("${test.prop}");
Resource[] resources = (Resource[]) editor.getValue();
assertEquals("foo-${bar}", resources[0].getFilename());
assertEquals("foo", resources[0].getFilename());
}
finally {
System.getProperties().remove("test.prop");
@@ -71,7 +71,7 @@ public class ResourceArrayPropertyEditorTests {
}
@Test
public void testStrictSystemPropertyReplacement() {
public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceArrayPropertyEditor(
new PathMatchingResourcePatternResolver(), new StandardEnvironment(),
false);