1
1
/*
2
- * Copyright 2002-2009 the original author or authors.
2
+ * Copyright 2002-2010 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
30
30
*/
31
31
public class URIEditorTests {
32
32
33
- @ Test
34
- public void standardURI () throws Exception {
33
+ private void doTestURI (String uriSpec ) {
35
34
PropertyEditor uriEditor = new URIEditor ();
36
- uriEditor .
setAsText (
"mailto:[email protected] " );
35
+ uriEditor .setAsText (uriSpec );
37
36
Object value = uriEditor .getValue ();
38
37
assertTrue (value instanceof URI );
39
38
URI uri = (URI ) value ;
40
- assertEquals (uri .toString (), uriEditor .getAsText ());
39
+ assertEquals (uriSpec , uri .toString ());
40
+ }
41
+
42
+ @ Test
43
+ public void standardURI () throws Exception {
44
+ doTestURI (
"mailto:[email protected] " );
45
+ }
46
+
47
+ @ Test
48
+ public void withNonExistentResource () throws Exception {
49
+ doTestURI ("gonna:/freak/in/the/morning/freak/in/the.evening" );
41
50
}
42
51
43
52
@ Test
44
53
public void standardURL () throws Exception {
45
- PropertyEditor uriEditor = new URIEditor ( );
46
- uriEditor . setAsText ( "http://www.springframework.org" );
47
- Object value = uriEditor . getValue ();
48
- assertTrue ( value instanceof URI );
49
- URI uri = ( URI ) value ;
50
- assertEquals ( uri . toString (), uriEditor . getAsText () );
54
+ doTestURI ( "http://www.springframework.org" );
55
+ }
56
+
57
+ @ Test
58
+ public void standardURLWithFragment () throws Exception {
59
+ doTestURI ( "http://www.springframework.org#1" );
51
60
}
52
61
53
62
@ Test
@@ -57,7 +66,7 @@ public void standardURLWithWhitespace() throws Exception {
57
66
Object value = uriEditor .getValue ();
58
67
assertTrue (value instanceof URI );
59
68
URI uri = (URI ) value ;
60
- assertEquals (uri . toString (), uriEditor . getAsText ());
69
+ assertEquals ("http://www.springframework.org" , uri . toString ());
61
70
}
62
71
63
72
@ Test
@@ -95,16 +104,6 @@ public void classpathURLAsIs() throws Exception {
95
104
assertTrue (uri .getScheme ().startsWith ("classpath" ));
96
105
}
97
106
98
- @ Test
99
- public void withNonExistentResource () throws Exception {
100
- PropertyEditor uriEditor = new URIEditor ();
101
- uriEditor .setAsText ("gonna:/freak/in/the/morning/freak/in/the.evening" );
102
- Object value = uriEditor .getValue ();
103
- assertTrue (value instanceof URI );
104
- URI uri = (URI ) value ;
105
- assertEquals (uri .toString (), uriEditor .getAsText ());
106
- }
107
-
108
107
@ Test
109
108
public void setAsTextWithNull () throws Exception {
110
109
PropertyEditor uriEditor = new URIEditor ();
0 commit comments