Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 89098 invoked from network); 10 Oct 2006 19:36:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Oct 2006 19:36:55 -0000 Received: (qmail 39539 invoked by uid 500); 10 Oct 2006 19:36:54 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 39517 invoked by uid 500); 10 Oct 2006 19:36:54 -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 39506 invoked by uid 99); 10 Oct 2006 19:36:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Oct 2006 12:36:54 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Oct 2006 12:36:54 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id BDF851A981A; Tue, 10 Oct 2006 12:36:33 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r462518 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java Date: Tue, 10 Oct 2006 19:36:33 -0000 To: harmony-commits@incubator.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061010193633.BDF851A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: hindessm Date: Tue Oct 10 12:36:33 2006 New Revision: 462518 URL: http://svn.apache.org/viewvc?view=rev&rev=462518 Log: Allow junit to handle exceptions Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java?view=diff&rev=462518&r1=462517&r2=462518 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java Tue Oct 10 12:36:33 2006 @@ -95,59 +95,47 @@ /** * @tests java.net.JarURLConnection#getJarFile() */ - public void test_getJarFile() { + public void test_getJarFile() + throws MalformedURLException,IOException { URL url = null; - try { - url = new URL("jar:" - + Support_Resources.getResourceURL("/JUC/lf.jar!/missing")); - } catch (MalformedURLException e) { - fail("Unexpected MalformedURLException : " + e.getMessage()); - } catch (java.io.IOException e) { - fail("Unexpected IOException : " + e.getMessage()); - } + url = new URL("jar:" + + Support_Resources.getResourceURL("/JUC/lf.jar!/missing")); + JarURLConnection connection = null; - try { - connection = (JarURLConnection) url.openConnection(); - } catch (IOException e) { - fail("Unexpected IOException : " + e.getMessage()); - } - int exception = 0; + connection = (JarURLConnection) url.openConnection(); try { connection.connect(); + fail("Did not throw exception on connect"); } catch (IOException e) { - exception = 1; + // expected } - assertEquals("Did not throw exception on connect", 1, exception); - exception = 0; + try { connection.getJarFile(); + fail("Did not throw exception after connect"); } catch (IOException e) { - exception = 1; + // expected } - assertEquals("Did not throw exception after connect", 1, exception); + File resources = Support_Resources.createTempFolder(); - try { - Support_Resources.copyFile(resources, null, "hyts_att.jar"); - File file = new File(resources.toString() + "/hyts_att.jar"); - URL fUrl1 = new URL("jar:file:" + file.getPath() + "!/"); - JarURLConnection con1 = (JarURLConnection) fUrl1.openConnection(); - ZipFile jf1 = con1.getJarFile(); - JarURLConnection con2 = (JarURLConnection) fUrl1.openConnection(); - ZipFile jf2 = con2.getJarFile(); - assertTrue("file: JarFiles not the same", jf1 == jf2); - jf1.close(); - assertTrue("File should exist", file.exists()); - new URL("jar:" + Support_Resources.getResourceURL("/JUC/lf.jar!/")); - con1 = (JarURLConnection) fUrl1.openConnection(); - jf1 = con1.getJarFile(); - con2 = (JarURLConnection) fUrl1.openConnection(); - jf2 = con2.getJarFile(); - assertTrue("http: JarFiles not the same", jf1 == jf2); - jf1.close(); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected exception : " + e.getMessage()); - } + + Support_Resources.copyFile(resources, null, "hyts_att.jar"); + File file = new File(resources.toString() + "/hyts_att.jar"); + URL fUrl1 = new URL("jar:file:" + file.getPath() + "!/"); + JarURLConnection con1 = (JarURLConnection) fUrl1.openConnection(); + ZipFile jf1 = con1.getJarFile(); + JarURLConnection con2 = (JarURLConnection) fUrl1.openConnection(); + ZipFile jf2 = con2.getJarFile(); + assertTrue("file: JarFiles not the same", jf1 == jf2); + jf1.close(); + assertTrue("File should exist", file.exists()); + new URL("jar:" + Support_Resources.getResourceURL("/JUC/lf.jar!/")); + con1 = (JarURLConnection) fUrl1.openConnection(); + jf1 = con1.getJarFile(); + con2 = (JarURLConnection) fUrl1.openConnection(); + jf2 = con2.getJarFile(); + assertTrue("http: JarFiles not the same", jf1 == jf2); + jf1.close(); } /**