You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2006/10/10 21:36:33 UTC

svn commit: r462518 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java

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();
 	}
 
 	/**