This is the mail archive of the
mauve-discuss@sources.redhat.com
mailing list for the Mauve project.
Re: gnu/testlet/java/util/jar/JarFile/basic.java
- From: Mark Wielaard <mark at klomp dot org>
- To: John Leuner <jewel at pixie dot co dot za>
- Cc: raif at fl dot net dot au, Mauve <mauve-discuss at sources dot redhat dot com>
- Date: 13 Feb 2003 21:26:24 +0100
- Subject: Re: gnu/testlet/java/util/jar/JarFile/basic.java
- Organization:
- References: <200302042043.07439.raif@fl.net.au> <1044373522.634.1.camel@cmalu>
Hi,
On Tue, 2003-02-04 at 16:45, John Leuner wrote:
> I'm not sure if this test is correct, particularly the JarFile.entries()
> tests.
I think this test is a bit to strict. I could not found any order that
the Enumeration should follow. When the order of the entries matters an
application should probably use JarInputStream anyway. I have changed
the test a little so that it only tests that the number of entries and
the name and content of each entry match.
2003-02-13 Mark Wielaard <mark@klomp.org>
* gnu/testlet/java/util/jar/JarFile/basic.java: Don't test order,
only test that all entries have the correct content.
If there are applications for which the order matters I like to hear
about them.
Cheers,
Mark
Index: gnu/testlet/java/util/jar/JarFile/basic.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/jar/JarFile/basic.java,v
retrieving revision 1.2
diff -u -r1.2 basic.java
--- gnu/testlet/java/util/jar/JarFile/basic.java 4 Feb 2003 14:40:01 -0000 1.2
+++ gnu/testlet/java/util/jar/JarFile/basic.java 13 Feb 2003 20:25:16 -0000
@@ -43,33 +43,31 @@
But it would seem likely that someone will write a program expecting the files to be enumerated the same way every time
*/
- int item = 1;
+ int item = 0;
Enumeration e = jarfile.entries();
while(e.hasMoreElements())
{
JarEntry je = (JarEntry) e.nextElement();
+ String n = je.getName();
String s = new BufferedReader(new InputStreamReader(jarfile.getInputStream(je))).readLine();
- switch(item)
- {
- case 1:
- harness.check(s == null);
- break;
- case 2:
- harness.check(s.equals("Manifest-Version: 1.0"));
- break;
- case 3:
- harness.check(s.equals("this jar file was created with the jar tool for IBM JDK 1.3"));
- break;
- case 4:
- harness.check(s.equals("We seek peace. We strive for peace. And sometimes peace must be defended. A future lived at the mercy of terrible threats is no peace at all. If war is forced upon us, we will fight in a just cause and by just means -- sparing, in every way we can, the innocent. And if war is forced upon us, we will fight with the full force and might of the United States military -- and we will prevail."));
- break;
- case 5:
- harness.check(s.equals("I am he as you are he as you are me and we are all together."));
- break;
- }
- // System.out.println("item " + item + " and string '" + s + "'");
+
+ if ("META-INF/".equals(n))
+ harness.check(s == null);
+ else if ("META-INF/MANIFEST.MF".equals(n))
+ harness.check(s.equals("Manifest-Version: 1.0"));
+ else if ("file1".equals(n))
+ harness.check(s.equals("this jar file was created with the jar tool for IBM JDK 1.3"));
+ else if ("file2".equals(n))
+ harness.check(s.equals("We seek peace. We strive for peace. And sometimes peace must be defended. A future lived at the mercy of terrible threats is no peace at all. If war is forced upon us, we will fight in a just cause and by just means -- sparing, in every way we can, the innocent. And if war is forced upon us, we will fight with the full force and might of the United States military -- and we will prevail."));
+ else if ("file3".equals(n))
+ harness.check(s.equals("I am he as you are he as you are me and we are all together."));
+ else
+ harness.check(false, "Unexpected entry: " + n);
+
item++;
}
+
+ harness.check(item, 5);
jarfile.close();