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(" http://www.springframework.org ");
Object value = uriEditor.getValue();
assertTrue(value instanceof URI);
URI uri = (URI) value;
assertEquals("http://www.springframework.org", uri.toString());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URIEditorTests method encodeURI.
@Test
public void encodeURI() throws Exception {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText("http://example.com/spaces and €");
Object value = uriEditor.getValue();
assertTrue(value instanceof URI);
URI uri = (URI) value;
assertEquals(uri.toString(), uriEditor.getAsText());
assertEquals("http://example.com/spaces%20and%20%E2%82%AC", uri.toASCIIString());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URIEditorTests method classpathURLWithWhitespace.
@Test
public void classpathURLWithWhitespace() throws Exception {
PropertyEditor uriEditor = new URIEditor(getClass().getClassLoader());
uriEditor.setAsText(" classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class ");
Object value = uriEditor.getValue();
assertTrue(value instanceof URI);
URI uri = (URI) value;
assertEquals(uri.toString(), uriEditor.getAsText());
assertTrue(!uri.getScheme().startsWith("classpath"));
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URIEditorTests method getAsTextReturnsEmptyStringIfValueNotSet.
@Test
public void getAsTextReturnsEmptyStringIfValueNotSet() throws Exception {
PropertyEditor uriEditor = new URIEditor();
assertEquals("", uriEditor.getAsText());
}
use of java.beans.PropertyEditor in project spring-framework by spring-projects.
the class URIEditorTests method classpathURLAsIs.
@Test
public void classpathURLAsIs() throws Exception {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText("classpath:test.txt");
Object value = uriEditor.getValue();
assertTrue(value instanceof URI);
URI uri = (URI) value;
assertEquals(uri.toString(), uriEditor.getAsText());
assertTrue(uri.getScheme().startsWith("classpath"));
}
Aggregations