use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class CustomEditorTests method testLocaleEditor.
@Test
public void testLocaleEditor() {
PropertyEditor localeEditor = new LocaleEditor();
localeEditor.setAsText("en_CA");
assertEquals(Locale.CANADA, localeEditor.getValue());
assertEquals("en_CA", localeEditor.getAsText());
localeEditor = new LocaleEditor();
assertEquals("", localeEditor.getAsText());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class CustomEditorTests method testClassEditorWithArray.
@Test
public void testClassEditorWithArray() {
PropertyEditor classEditor = new ClassEditor();
classEditor.setAsText("org.springframework.tests.sample.beans.TestBean[]");
assertEquals(TestBean[].class, classEditor.getValue());
assertEquals("org.springframework.tests.sample.beans.TestBean[]", classEditor.getAsText());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class FileEditorTests method testAbsoluteFileName.
@Test
public void testAbsoluteFileName() throws Exception {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("/no_way_this_file_is_found.doc");
Object value = fileEditor.getValue();
assertTrue(value instanceof File);
File file = (File) value;
assertTrue(!file.exists());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class FileEditorTests method testWithNonExistentFile.
@Test
public void testWithNonExistentFile() throws Exception {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("file:no_way_this_file_is_found.doc");
Object value = fileEditor.getValue();
assertTrue(value instanceof File);
File file = (File) value;
assertTrue(!file.exists());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class FileEditorTests method testUnqualifiedFileNameFound.
@Test
public void testUnqualifiedFileNameFound() throws Exception {
PropertyEditor fileEditor = new FileEditor();
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class";
fileEditor.setAsText(fileName);
Object value = fileEditor.getValue();
assertTrue(value instanceof File);
File file = (File) value;
assertTrue(file.exists());
String absolutePath = file.getAbsolutePath().replace('\\', '/');
assertTrue(absolutePath.endsWith(fileName));
}
Aggregations