Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 84171 invoked from network); 9 May 2006 11:34:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 May 2006 11:34:35 -0000 Received: (qmail 18886 invoked by uid 500); 9 May 2006 11:34:22 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 18838 invoked by uid 500); 9 May 2006 11:34:22 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 18813 invoked by uid 99); 9 May 2006 11:34:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 May 2006 04:34:22 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,USERPASS X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 09 May 2006 04:34:21 -0700 Received: (qmail 83714 invoked by uid 65534); 9 May 2006 11:34:00 -0000 Message-ID: <20060509113400.83713.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r405390 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URITest.java Date: Tue, 09 May 2006 11:33:59 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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); } }