You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/05/09 13:33:59 UTC
svn commit: r405390 -
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java
Author: tellison
Date: Tue May 9 04:33:56 2006
New Revision: 405390
URL: http://svn.apache.org/viewcvs?rev=405390&view=rev
Log:
Updated to use JUnit exception handling for unexpected expeceptions
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java?rev=405390&r1=405389&r2=405390&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java Tue May 9 04:33:56 2006
@@ -25,7 +25,7 @@
/**
* @tests java.net.URI(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws URISyntaxException {
// Regression test for HARMONY-23
try {
new URI("%3");
@@ -37,29 +37,24 @@
// Regression test for HARMONY-25
// if port value is negative, the authority should be considered registry-based.
+ URI uri = new URI("http://host:-8096/path/index.html");
+ assertEquals("Assert 2: returned wrong port value,", -1, uri.getPort());
+ assertEquals("Assert 3: returned wrong host value,", null, uri.getHost());
try {
- URI uri = new URI("http://host:-8096/path/index.html");
- assertEquals("Assert 2: returned wrong port value,", -1, uri.getPort());
- assertEquals("Assert 3: returned wrong host value,", null, uri.getHost());
- try {
- uri.parseServerAuthority();
- fail("Assert 4: Expected URISyntaxException");
- } catch (URISyntaxException e){
- // Expected
- }
-
- uri = new URI("http","//myhost:-8096", null);
- assertEquals("Assert 5: returned wrong port value,", -1, uri.getPort());
- assertEquals("Assert 6: returned wrong host value,", null, uri.getHost());
- try {
- uri.parseServerAuthority();
- fail("Assert 7: Expected URISyntaxException");
- } catch (URISyntaxException e){
- // Expected
- }
-
- } catch (URISyntaxException e) {
- fail("Assert 8: Unexpected URI syntax exception");
+ uri.parseServerAuthority();
+ fail("Assert 4: Expected URISyntaxException");
+ } catch (URISyntaxException e){
+ // Expected
+ }
+
+ uri = new URI("http","//myhost:-8096", null);
+ assertEquals("Assert 5: returned wrong port value,", -1, uri.getPort());
+ assertEquals("Assert 6: returned wrong host value,", null, uri.getHost());
+ try {
+ uri.parseServerAuthority();
+ fail("Assert 7: Expected URISyntaxException");
+ } catch (URISyntaxException e){
+ // Expected
}
}
@@ -80,59 +75,50 @@
/**
* @tests java.net.URI#relativize(java.net.URI)
*/
- public void test_relativizeLjava_net_URI(){
- try {
- URI a = new URI("http://host/dir");
- URI b = new URI("http://host/dir/file?query");
- assertEquals("Assert 0: URI relativized incorrectly,",
- new URI("file?query"), a.relativize(b));
-
- // One URI with empty host
- a = new URI("file:///~/first");
- b = new URI("file://tools/~/first");
- assertEquals("Assert 1: URI relativized incorrectly,",
- new URI("file://tools/~/first"), a.relativize(b));
- assertEquals("Assert 2: URI relativized incorrectly,",
- new URI("file:///~/first"), b.relativize(a));
+ public void test_relativizeLjava_net_URI() throws URISyntaxException{
+ URI a = new URI("http://host/dir");
+ URI b = new URI("http://host/dir/file?query");
+ assertEquals("Assert 0: URI relativized incorrectly,",
+ new URI("file?query"), a.relativize(b));
+
+ // One URI with empty host
+ a = new URI("file:///~/first");
+ b = new URI("file://tools/~/first");
+ assertEquals("Assert 1: URI relativized incorrectly,",
+ new URI("file://tools/~/first"), a.relativize(b));
+ assertEquals("Assert 2: URI relativized incorrectly,",
+ new URI("file:///~/first"), b.relativize(a));
- // Both URIs with empty hosts
- b = new URI("file:///~/second");
- assertEquals("Assert 3: URI relativized incorrectly,",
- new URI("file:///~/second"), a.relativize(b));
- assertEquals("Assert 4: URI relativized incorrectly,",
- new URI("file:///~/first"), b.relativize(a));
- } catch (URISyntaxException e) {
- fail("Assert 6: Unexpected URI syntax exception");
- }
+ // Both URIs with empty hosts
+ b = new URI("file:///~/second");
+ assertEquals("Assert 3: URI relativized incorrectly,",
+ new URI("file:///~/second"), a.relativize(b));
+ assertEquals("Assert 4: URI relativized incorrectly,",
+ new URI("file:///~/first"), b.relativize(a));
}
/**
* @tests java.net.URI#compareTo(java.lang.Object)
*/
- public void test_compareToLjava_lang_Object(){
- try {
- URI uri1, uri2;
-
- // URIs whose host names have different casing
- uri1 = new URI("http://MixedCaseHost/path/resource");
- uri2 = new URI("http://mixedcasehost/path/resource");
- assertEquals("Assert 0: host name equality failure", 0, uri1.compareTo(uri2));
- assertEquals("Assert 1: host name equality failure", 0, uri1.compareTo(uri2));
+ public void test_compareToLjava_lang_Object() throws URISyntaxException{
+ URI uri1, uri2;
- // URIs with one undefined component (port)
- uri1 = new URI("http://anyhost:80/path/resource");
- uri2 = new URI("http://anyhost/path/resource");
- assertTrue("Assert 2: comparison failure", uri1.compareTo(uri2) > 0);
- assertTrue("Assert 3: comparison failure", uri2.compareTo(uri1) < 0);
-
- // URIs with one undefined component (user-info)
- uri1 = new URI("http://user-info@anyhost/path/resource");
- uri2 = new URI("http://anyhost/path/resource");
- assertTrue("Assert 4: comparison failure", uri1.compareTo(uri2) > 0);
- assertTrue("Assert 5: comparison failure", uri2.compareTo(uri1) < 0);
+ // URIs whose host names have different casing
+ uri1 = new URI("http://MixedCaseHost/path/resource");
+ uri2 = new URI("http://mixedcasehost/path/resource");
+ assertEquals("Assert 0: host name equality failure", 0, uri1.compareTo(uri2));
+ assertEquals("Assert 1: host name equality failure", 0, uri1.compareTo(uri2));
- } catch (URISyntaxException e) {
- fail("Assert 6: Unexpected URI syntax exception");
- }
+ // URIs with one undefined component (port)
+ uri1 = new URI("http://anyhost:80/path/resource");
+ uri2 = new URI("http://anyhost/path/resource");
+ assertTrue("Assert 2: comparison failure", uri1.compareTo(uri2) > 0);
+ assertTrue("Assert 3: comparison failure", uri2.compareTo(uri1) < 0);
+
+ // URIs with one undefined component (user-info)
+ uri1 = new URI("http://user-info@anyhost/path/resource");
+ uri2 = new URI("http://anyhost/path/resource");
+ assertTrue("Assert 4: comparison failure", uri1.compareTo(uri2) > 0);
+ assertTrue("Assert 5: comparison failure", uri2.compareTo(uri1) < 0);
}
}