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();
boolean condition = value instanceof File;
assertThat(condition).isTrue();
File file = (File) value;
assertThat(file.exists()).isTrue();
String absolutePath = file.getAbsolutePath().replace('\\', '/');
assertThat(absolutePath.endsWith(fileName)).isTrue();
}
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();
boolean condition1 = value instanceof File;
assertThat(condition1).isTrue();
File file = (File) value;
boolean condition = !file.exists();
assertThat(condition).isTrue();
}
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();
boolean condition1 = value instanceof File;
assertThat(condition1).isTrue();
File file = (File) value;
boolean condition = !file.exists();
assertThat(condition).isTrue();
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class PathEditorTests method testAbsolutePath.
@Test
public void testAbsolutePath() {
PropertyEditor pathEditor = new PathEditor();
pathEditor.setAsText("/no_way_this_file_is_found.doc");
Object value = pathEditor.getValue();
assertThat(value instanceof Path).isTrue();
Path path = (Path) value;
assertThat(!path.toFile().exists()).isTrue();
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class PathEditorTests method testUnqualifiedPathNameNotFound.
@Test
public void testUnqualifiedPathNameNotFound() {
PropertyEditor pathEditor = new PathEditor();
String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".clazz";
pathEditor.setAsText(fileName);
Object value = pathEditor.getValue();
assertThat(value instanceof Path).isTrue();
Path path = (Path) value;
File file = path.toFile();
assertThat(file.exists()).isFalse();
String absolutePath = file.getAbsolutePath();
if (File.separatorChar == '\\') {
absolutePath = absolutePath.replace('\\', '/');
}
assertThat(absolutePath.endsWith(fileName)).isTrue();
}
Aggregations