This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: Added test to gnu/testlet/java/net/URLConnection/Jar.java
- From: Wolfgang Baer <WBaer at gmx dot de>
- To: mauve-patches at sources dot redhat dot com
- Date: Thu, 02 Mar 2006 19:46:37 +0100
- Subject: FYI: Added test to gnu/testlet/java/net/URLConnection/Jar.java
Hi,
this patch adds one more specialised test to show that
the FileNotFoundException is thrown in the connect method.
The other test is only reworked to be in its own try/catch.
We are currently failing both tests. Patch pending.
2006-03-02 Wolfgang Baer <WBaer@gmx.de>
* gnu/testlet/java/net/URLConnection/Jar.java (test):
Added one more specialised test.
Wolfgang
Index: Jar.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/URLConnection/Jar.java,v
retrieving revision 1.1
diff -u -r1.1 Jar.java
--- Jar.java 20 May 2005 18:47:29 -0000 1.1
+++ Jar.java 2 Mar 2006 18:35:55 -0000
@@ -2,8 +2,9 @@
/* Jar.java -- Tests Jar URL connection
- Copyright (c) 2005 by Free Software Foundation, Inc.
+ Copyright (c) 2005, 2006 by Free Software Foundation, Inc.
Written by Tom Tromey <tromey@redhat.com>
+ Extended by Wolfgang Baer <WBaer@gmx.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -15,23 +16,24 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA */
+ along with this program; if not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA. */
package gnu.testlet.java.net.URLConnection;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
-import java.net.*;
-import java.io.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.JarURLConnection;
+import java.net.URL;
public class Jar implements Testlet
{
public void test(TestHarness harness)
{
harness.checkPoint("jar: URL with missing entry");
- boolean ok = false;
try
{
File jarfile = harness.getResourceFile("gnu#testlet#java#util#jar#JarFile#jartest.jar");
@@ -39,16 +41,44 @@
URL url = new URL("jar:file:" + filename + "!/nosuchfile.txt");
- InputStream is = url.openStream();
- }
- catch (FileNotFoundException _)
- {
- ok = true;
- }
+ // Test via JarURLConnection
+ // FileNotFoundException must already be thrown in connect
+ JarURLConnection connection = null;
+ try
+ {
+ connection = (JarURLConnection) url.openConnection();
+ connection.connect();
+ harness.check(false);
+ }
+ catch (FileNotFoundException e)
+ {
+ harness.check(true);
+ }
+ catch (Exception e)
+ {
+ harness.check(false);
+ }
+
+ // Test via direct opening of the stream on the URL object
+ try
+ {
+ url.openStream();
+ harness.check(false);
+ }
+ catch (FileNotFoundException e)
+ {
+ harness.check(true);
+ }
+ catch (Exception e)
+ {
+ harness.check(false);
+ }
+
+ }
catch (Throwable e)
{
+ harness.debug("Unexpected exception in testcase.");
harness.debug(e);
}
- harness.check(ok);
}
}