use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URLEditorTests method testSetAsTextWithNull.
@Test
public void testSetAsTextWithNull() throws Exception {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText(null);
assertThat(urlEditor.getValue()).isNull();
assertThat(urlEditor.getAsText()).isEqualTo("");
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URLEditorTests method testStandardURI.
@Test
public void testStandardURI() throws Exception {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText("mailto:juergen.hoeller@interface21.com");
Object value = urlEditor.getValue();
boolean condition = value instanceof URL;
assertThat(condition).isTrue();
URL url = (URL) value;
assertThat(urlEditor.getAsText()).isEqualTo(url.toExternalForm());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URLEditorTests method testWithNonExistentResource.
@Test
public void testWithNonExistentResource() throws Exception {
PropertyEditor urlEditor = new URLEditor();
assertThatIllegalArgumentException().isThrownBy(() -> urlEditor.setAsText("gonna:/freak/in/the/morning/freak/in/the.evening"));
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URIEditorTests method standardURLWithWhitespace.
@Test
public void standardURLWithWhitespace() throws Exception {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText(" https://www.springframework.org ");
Object value = uriEditor.getValue();
boolean condition = value instanceof URI;
assertThat(condition).isTrue();
URI uri = (URI) value;
assertThat(uri.toString()).isEqualTo("https://www.springframework.org");
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URIEditorTests method classpathURL.
@Test
public void classpathURL() throws Exception {
PropertyEditor uriEditor = new URIEditor(getClass().getClassLoader());
uriEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class");
Object value = uriEditor.getValue();
boolean condition1 = value instanceof URI;
assertThat(condition1).isTrue();
URI uri = (URI) value;
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
boolean condition = !uri.getScheme().startsWith("classpath");
assertThat(condition).isTrue();
}
Aggregations