use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class ResourceEditorTests method testStrictSystemPropertyReplacement.
@Test(expected = IllegalArgumentException.class)
public void testStrictSystemPropertyReplacement() {
PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false);
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}-${bar}");
Resource resolved = (Resource) editor.getValue();
assertEquals("foo-${bar}", resolved.getFilename());
} finally {
System.getProperties().remove("test.prop");
}
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class ResourceEditorTests method testSystemPropertyReplacement.
@Test
public void testSystemPropertyReplacement() {
PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}-${bar}");
Resource resolved = (Resource) editor.getValue();
assertEquals("foo-${bar}", resolved.getFilename());
} finally {
System.getProperties().remove("test.prop");
}
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class ResourceArrayPropertyEditorTests method testPatternResource.
@Test
public void testPatternResource() throws Exception {
// 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
// comes first (like in Spring Build) then it is OK.
PropertyEditor editor = new ResourceArrayPropertyEditor();
editor.setAsText("classpath*:org/springframework/core/io/support/Resource*Editor.class");
Resource[] resources = (Resource[]) editor.getValue();
assertNotNull(resources);
assertTrue(resources[0].exists());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class ResourceArrayPropertyEditorTests method testStrictSystemPropertyReplacement.
@Test(expected = IllegalArgumentException.class)
public void testStrictSystemPropertyReplacement() {
PropertyEditor editor = new ResourceArrayPropertyEditor(new PathMatchingResourcePatternResolver(), new StandardEnvironment(), false);
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}-${bar}");
Resource[] resources = (Resource[]) editor.getValue();
assertEquals("foo-${bar}", resources[0].getFilename());
} finally {
System.getProperties().remove("test.prop");
}
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class ResourceArrayPropertyEditorTests method testSystemPropertyReplacement.
@Test
public void testSystemPropertyReplacement() {
PropertyEditor editor = new ResourceArrayPropertyEditor();
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}-${bar}");
Resource[] resources = (Resource[]) editor.getValue();
assertEquals("foo-${bar}", resources[0].getFilename());
} finally {
System.getProperties().remove("test.prop");
}
}
Aggregations