harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r646264 [2/13] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/build/platform/ depends/files/ modules/accessibility/ modules/annotation/ modules/applet/ modules/archive/ modules/archive/src/main/java/java/util/jar/ mo...
Date Wed, 09 Apr 2008 11:02:07 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/java/util/jar/Manifest.java Wed Apr  9 04:01:14 2008
@@ -20,39 +20,58 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.security.AccessController;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.harmony.luni.util.PriviAction;
+import org.apache.harmony.archive.internal.nls.Messages;
+import org.apache.harmony.luni.util.InputStreamExposer;
+import org.apache.harmony.luni.util.ThreadLocalCache;
 
 /**
  * The Manifest class is used to obtain attribute information for a JarFile and
  * its entries.
- * 
  */
 public class Manifest implements Cloneable {
-    private static final int LINE_LENGTH_LIMIT = 70;
+    static final int LINE_LENGTH_LIMIT = 72;
 
     private static final byte[] LINE_SEPARATOR = new byte[] { '\r', '\n' };
 
+    private static final byte[] VALUE_SEPARATOR = new byte[] { ':', ' ' };
+
     private static final Attributes.Name NAME_ATTRIBUTE = new Attributes.Name(
             "Name"); //$NON-NLS-1$
 
     private Attributes mainAttributes = new Attributes();
 
-    private HashMap<String, Attributes> entryAttributes = new HashMap<String, Attributes>();
+    private HashMap<String, Attributes> entries = new HashMap<String, Attributes>();
+
+    static class Chunk {
+        int start;
+        int end;
+
+        Chunk(int start, int end) {
+            this.start = start;
+            this.end = end;
+        }
+    }
+
+    private HashMap<String, Chunk> chunks;
 
-    private HashMap<String, byte[]> chunks;
+    /**
+     * Manifest bytes are used for delayed entry parsing.
+     */
+    private InitManifest im;
 
     /**
-     * The data chunk of Main Attributes in the manifest is needed in
+     * The end of the main attributes section in the manifest is needed in
      * verification.
      */
-    private byte[] mainAttributesChunk;
+    private int mainEnd;
 
     /**
      * Constructs a new Manifest instance.
@@ -86,13 +105,13 @@
     @SuppressWarnings("unchecked")
     public Manifest(Manifest man) {
         mainAttributes = (Attributes) man.mainAttributes.clone();
-        entryAttributes = (HashMap<String, Attributes>) man.entryAttributes
-                .clone();
+        entries = (HashMap<String, Attributes>) ((HashMap<String, Attributes>) man
+                .getEntries()).clone();
     }
 
     Manifest(InputStream is, boolean readChunks) throws IOException {
         if (readChunks) {
-            chunks = new HashMap<String, byte[]>();
+            chunks = new HashMap<String, Chunk>();
         }
         read(is);
     }
@@ -102,7 +121,8 @@
      * associated with this Manifest.
      */
     public void clear() {
-        entryAttributes.clear();
+        im = null;
+        entries.clear();
         mainAttributes.clear();
     }
 
@@ -123,7 +143,20 @@
      * @return A Map of entry attributes
      */
     public Map<String, Attributes> getEntries() {
-        return entryAttributes;
+        initEntries();
+        return entries;
+    }
+
+    private void initEntries() {
+        if (im == null) {
+            return;
+        }
+        // try {
+        // im.initEntries(entries, chunks);
+        // } catch (IOException ioe) {
+        // throw new RuntimeException(ioe);
+        // }
+        // im = null;
     }
 
     /**
@@ -170,9 +203,27 @@
      *             If an error occurs reading the Manifest.
      */
     public void read(InputStream is) throws IOException {
-        InitManifest initManifest = new InitManifest(is, mainAttributes,
-                entryAttributes, chunks, null);
-        mainAttributesChunk = initManifest.getMainAttributesChunk();
+        byte[] buf;
+        try {
+            buf = InputStreamExposer.expose(is);
+        } catch (OutOfMemoryError oome) {
+            throw new IOException(Messages.getString("archive.2E")); //$NON-NLS-1$
+        }
+
+        // a workaround for HARMONY-5662
+        // replace EOF and NUL with another new line
+        // which does not trigger an error
+        byte b = buf[buf.length - 1];
+        if (0 == b || 26 == b) {
+            buf[buf.length - 1] = '\n';
+        }
+
+        im = new InitManifest(buf, mainAttributes,
+                Attributes.Name.MANIFEST_VERSION);
+        mainEnd = im.getPos();
+        // FIXME
+        im.initEntries(entries, chunks);
+        im = null;
     }
 
     /**
@@ -182,7 +233,7 @@
      */
     @Override
     public int hashCode() {
-        return mainAttributes.hashCode() ^ entryAttributes.hashCode();
+        return mainAttributes.hashCode() ^ getEntries().hashCode();
     }
 
     /**
@@ -206,10 +257,10 @@
         if (!mainAttributes.equals(((Manifest) o).mainAttributes)) {
             return false;
         }
-        return entryAttributes.equals(((Manifest) o).entryAttributes);
+        return getEntries().equals(((Manifest) o).getEntries());
     }
 
-    byte[] getChunk(String name) {
+    Chunk getChunk(String name) {
         return chunks.get(name);
     }
 
@@ -217,8 +268,8 @@
         chunks = null;
     }
 
-    byte[] getMainAttributesChunk() {
-        return mainAttributesChunk;
+    int getMainAttributesEnd() {
+        return mainEnd;
     }
 
     /**
@@ -234,99 +285,68 @@
      *             If an error occurs writing the Manifest
      */
     static void write(Manifest manifest, OutputStream out) throws IOException {
-        Charset charset = null;
-        String encoding = AccessController
-                .doPrivileged(new PriviAction<String>("manifest.write.encoding")); //$NON-NLS-1$
-        if (encoding != null) {
-            if (encoding.length() == 0) {
-                encoding = "UTF8"; //$NON-NLS-1$
-            }
-            charset = Charset.forName(encoding);
-        }
+        CharsetEncoder encoder = ThreadLocalCache.utf8Encoder.get();
+        ByteBuffer buffer = ThreadLocalCache.byteBuffer.get();
+
         String version = manifest.mainAttributes
                 .getValue(Attributes.Name.MANIFEST_VERSION);
         if (version != null) {
-            writeEntry(out, charset, Attributes.Name.MANIFEST_VERSION, version);
+            writeEntry(out, Attributes.Name.MANIFEST_VERSION, version, encoder,
+                    buffer);
             Iterator<?> entries = manifest.mainAttributes.keySet().iterator();
             while (entries.hasNext()) {
                 Attributes.Name name = (Attributes.Name) entries.next();
                 if (!name.equals(Attributes.Name.MANIFEST_VERSION)) {
-                    writeEntry(out, charset, name, manifest.mainAttributes
-                            .getValue(name));
+                    writeEntry(out, name, manifest.mainAttributes
+                            .getValue(name), encoder, buffer);
                 }
             }
         }
         out.write(LINE_SEPARATOR);
-        Iterator<String> i = manifest.entryAttributes.keySet().iterator();
+        Iterator<String> i = manifest.getEntries().keySet().iterator();
         while (i.hasNext()) {
             String key = i.next();
-            writeEntry(out, charset, NAME_ATTRIBUTE, key);
-            Attributes attrib = manifest.entryAttributes.get(key);
+            writeEntry(out, NAME_ATTRIBUTE, key, encoder, buffer);
+            Attributes attrib = manifest.entries.get(key);
             Iterator<?> entries = attrib.keySet().iterator();
             while (entries.hasNext()) {
                 Attributes.Name name = (Attributes.Name) entries.next();
-                writeEntry(out, charset, name, attrib.getValue(name));
+                writeEntry(out, name, attrib.getValue(name), encoder, buffer);
             }
             out.write(LINE_SEPARATOR);
         }
     }
 
-    private static void writeEntry(OutputStream os, Charset charset,
-            Attributes.Name name, String value) throws IOException {
-        int offset = 0;
-        int limit = LINE_LENGTH_LIMIT;
-        byte[] out = (name.toString() + ": ").getBytes("ISO8859_1"); //$NON-NLS-1$ //$NON-NLS-2$
-        if (out.length > limit) {
-            while (out.length - offset >= limit) {
-                int len = out.length - offset;
-                if (len > limit) {
-                    len = limit;
-                }
-                if (offset > 0) {
-                    os.write(' ');
-                }
-                os.write(out, offset, len);
-                os.write(LINE_SEPARATOR);
-                offset += len;
-                limit = LINE_LENGTH_LIMIT - 1;
-            }
+    private static void writeEntry(OutputStream os, Attributes.Name name,
+            String value, CharsetEncoder encoder, ByteBuffer bBuf)
+            throws IOException {
+        byte[] out = name.getBytes();
+        if (out.length > LINE_LENGTH_LIMIT) {
+            throw new IOException(Messages.getString(
+                    "archive.33", name, Integer.valueOf(LINE_LENGTH_LIMIT))); //$NON-NLS-1$
         }
-        int size = out.length - offset;
-        final byte[] outBuf = new byte[LINE_LENGTH_LIMIT];
-        System.arraycopy(out, offset, outBuf, 0, size);
-        for (int i = 0; i < value.length(); i++) {
-            char[] oneChar = new char[1];
-            oneChar[0] = value.charAt(i);
-            byte[] buf;
-            if (oneChar[0] < 128 || charset == null) {
-                byte[] oneByte = new byte[1];
-                oneByte[0] = (byte) oneChar[0];
-                buf = oneByte;
-            } else {
-                buf = charset.encode(CharBuffer.wrap(oneChar, 0, 1)).array();
-            }
-            if (size + buf.length > limit) {
-                if (limit != LINE_LENGTH_LIMIT) {
-                    os.write(' ');
-                }
-                os.write(outBuf, 0, size);
-                os.write(LINE_SEPARATOR);
-                limit = LINE_LENGTH_LIMIT - 1;
-                size = 0;
-            }
-            if (buf.length == 1) {
-                outBuf[size] = buf[0];
-            } else {
-                System.arraycopy(buf, 0, outBuf, size, buf.length);
-            }
-            size += buf.length;
-        }
-        if (size > 0) {
-            if (limit != LINE_LENGTH_LIMIT) {
-                os.write(' ');
+
+        os.write(out);
+        os.write(VALUE_SEPARATOR);
+
+        encoder.reset();
+        bBuf.clear().limit(LINE_LENGTH_LIMIT - out.length - 2);
+
+        CharBuffer cBuf = CharBuffer.wrap(value);
+        CoderResult r;
+
+        while (true) {
+            r = encoder.encode(cBuf, bBuf, true);
+            if (CoderResult.UNDERFLOW == r) {
+                r = encoder.flush(bBuf);
             }
-            os.write(outBuf, 0, size);
+            os.write(bBuf.array(), bBuf.arrayOffset(), bBuf.position());
             os.write(LINE_SEPARATOR);
+            if (CoderResult.UNDERFLOW == r) {
+                break;
+            }
+            os.write(' ');
+            bBuf.clear().limit(LINE_LENGTH_LIMIT - 1);
         }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties Wed Apr  9 04:01:14 2008
@@ -60,8 +60,11 @@
 archive.2A=Name too long: {0}
 archive.2B=String is too long
 archive.2C=No active entry
-archive.2D=Missing version string\: {0}
-archive.2E=Line too long
-archive.2F=Invalid attribute {0}
-archive.30={0} failed verification of {1}
-archive.31={0} has invalid digest for {1} in {2}
+archive.2D=Missing version attribute\: {0}
+archive.2E=Manifest is too long
+archive.2F=NUL character in a manifest
+archive.30=Invalid attribute {0}
+archive.31={0} failed verification of {1}
+archive.32={0} has invalid digest for {1} in {2}
+archive.33=A length of the encoded header name "{1}" exceeded maximum length {2}
+archive.34=A jar verifier does not support more than one entry with the same name  

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/main/java/org/apache/harmony/archive/util/Util.java Wed Apr  9 04:01:14 2008
@@ -30,40 +30,30 @@
                 return false;
             }
 
-            s1 = s1.substring(start1, start1 + length);
-            s2 = s2.substring(start2, start2 + length);
-
-            return toASCIILowerCase(s1).equals(toASCIILowerCase(s2));
-        }
-        throw new NullPointerException();
-    }
-
-    public static String toASCIILowerCase(String s) {
-        int len = s.length();
-        StringBuilder buffer = new StringBuilder(len);
-        for (int i = 0; i < len; i++) {
-            char c = s.charAt(i);
-            if ('A' <= c && c <= 'Z') {
-                buffer.append((char) (c + ('a' - 'A')));
-            } else {
-                buffer.append(c);
+            char c1, c2;
+            for (int i = 0; i < length; i++) {
+                if ((c1 = s1.charAt(start1++)) != (c2 = s2.charAt(start2++))
+                        && toASCIIUpperCase(c1) != toASCIIUpperCase(c2)) {
+                    return false;
+                }
             }
+            return true;
         }
-        return buffer.toString();
+        throw new NullPointerException();
     }
 
-    public static String toASCIIUpperCase(String s) {
-        int len = s.length();
-        StringBuilder buffer = new StringBuilder(len);
+    public static byte[] toASCIILowerCase(byte[] buf) {
+        int len = buf.length;
+        byte[] buffer = new byte[len];
         for (int i = 0; i < len; i++) {
-            char c = s.charAt(i);
-            if ('a' <= c && c <= 'z') {
-                buffer.append((char) (c - ('a' - 'A')));
+            byte b = buf[i];
+            if ('A' <= b && b <= 'Z') {
+                buffer[i] = (byte) (b + ('a' - 'A'));
             } else {
-                buffer.append(c);
+                buffer[i] = b;
             }
         }
-        return buffer.toString();
+        return buffer;
     }
 
     public static final boolean equalsIgnoreCase(String s1, String s2) {
@@ -86,6 +76,26 @@
         return true;
     }
 
+    public static final boolean equalsIgnoreCase(byte[] buf1, byte[] buf2) {
+        if (buf1 == buf2) {
+            return true;
+        }
+
+        if (buf1 == null || buf2 == null || buf1.length != buf2.length) {
+            return false;
+        }
+
+        byte b1, b2;
+
+        for (int i = 0; i < buf1.length; i++) {
+            if ((b1 = buf1[i]) != (b2 = buf2[i])
+                    && toASCIIUpperCase(b1) != toASCIIUpperCase(b2)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     public static final char toASCIILowerCase(char c) {
         if ('A' <= c && c <= 'Z') {
             return (char) (c + ('a' - 'A'));
@@ -98,5 +108,12 @@
             return (char) (c - ('a' - 'A'));
         }
         return c;
+    }
+
+    public static final byte toASCIIUpperCase(byte b) {
+        if ('a' <= b && b <= 'z') {
+            return (byte) (b - ('a' - 'A'));
+        }
+        return b;
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java Wed Apr  9 04:01:14 2008
@@ -26,12 +26,12 @@
 	/**
 	 * @tests java.util.jar.Attributes.Name#Name(java.lang.String)
 	 */
-	public void test_AttributesName_Constructor() {
+	public void testAttributesNameConstructor() {
 		// Regression for HARMONY-85
 		try {
 			new Attributes.Name(
 					"01234567890123456789012345678901234567890123456789012345678901234567890");
-			fail("Assert 0: should have thrown IllegalArgumentException");
+			fail("Should throw IllegalArgumentException");
 		} catch (IllegalArgumentException e) {
 			// expected
 		}

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java Wed Apr  9 04:01:14 2008
@@ -62,7 +62,7 @@
             jarFile.close();
         }
     }
-    
+
     /**
      * @throws IOException
      * @tests java.util.jar.JarEntry#JarEntry(java.util.jar.JarEntry)
@@ -89,8 +89,10 @@
         assertNotNull("Zip entry is null", zipEntry);
         jarEntry = new JarEntry(zipEntry);
         assertNotNull("Jar entry is null", jarEntry);
-        assertEquals("Wrong entry constructed--wrong name", entryName, jarEntry.getName());
-        assertEquals("Wrong entry constructed--wrong size", 311, jarEntry.getSize());
+        assertEquals("Wrong entry constructed--wrong name", entryName, jarEntry
+                .getName());
+        assertEquals("Wrong entry constructed--wrong size", 311, jarEntry
+                .getSize());
     }
 
     /**
@@ -105,22 +107,24 @@
         attrJar = new JarFile(file);
 
         jarEntry = attrJar.getJarEntry(attEntryName);
-        assertNotNull("Should have Manifest attributes", jarEntry.getAttributes());
+        assertNotNull("Should have Manifest attributes", jarEntry
+                .getAttributes());
 
         jarEntry = attrJar.getJarEntry(attEntryName2);
-        assertNull("Shouldn't have any Manifest attributes", jarEntry.getAttributes());
+        assertNull("Shouldn't have any Manifest attributes", jarEntry
+                .getAttributes());
         attrJar.close();
     }
 
     /**
      * @tests java.util.jar.JarEntry#getCertificates()
      */
-    public void test_getCertificates() throws Exception{
+    public void test_getCertificates() throws Exception {
         zipEntry = jarFile.getEntry(entryName2);
         jarEntry = new JarEntry(zipEntry);
-        assertNull("Shouldn't have any Certificates", jarEntry.getCertificates());
-        
-        //Regression Test for HARMONY-3424
+        assertNull(jarEntry.getCertificates());
+
+        // Regression Test for HARMONY-3424
         String jarFileName = "TestCodeSigners.jar";
         Support_Resources.copyFile(resources, null, jarFileName);
         File file = new File(resources, jarFileName);
@@ -129,10 +133,16 @@
         JarEntry jarEntry2 = jarFile.getJarEntry("Test.class");
         InputStream in = jarFile.getInputStream(jarEntry1);
         byte[] buffer = new byte[1024];
-         while(in.read(buffer)>=0);
-        in.close();
+        while (in.available() > 0) {
+            assertNull("getCertificates() should be null until the entry is read",
+                    jarEntry1.getCertificates());
+            assertNull(jarEntry2.getCertificates());
+            in.read(buffer);
+        }
+        assertEquals("the file is fully read", -1, in.read());
         assertNotNull(jarEntry1.getCertificates());
         assertNotNull(jarEntry2.getCertificates());
+        in.close();
     }
 
     /**
@@ -147,12 +157,17 @@
         InputStream in = jarFile.getInputStream(jarEntry);
         byte[] buffer = new byte[1024];
         while (in.available() > 0) {
+            assertNull("getCodeSigners() should be null until the entry is read",
+                    jarEntry.getCodeSigners());
             in.read(buffer);
         }
+        assertEquals("the file is fully read", -1, in.read());
         CodeSigner[] codeSigners = jarEntry.getCodeSigners();
         assertEquals(2, codeSigners.length);
-        List<?> certs_bob = codeSigners[0].getSignerCertPath().getCertificates();
-        List<?> certs_alice = codeSigners[1].getSignerCertPath().getCertificates();
+        List<?> certs_bob = codeSigners[0].getSignerCertPath()
+                .getCertificates();
+        List<?> certs_alice = codeSigners[1].getSignerCertPath()
+                .getCertificates();
         if (1 == certs_bob.size()) {
             List<?> temp = certs_bob;
             certs_bob = certs_alice;
@@ -160,7 +175,8 @@
         }
         assertEquals(2, certs_bob.size());
         assertEquals(1, certs_alice.size());
-        assertNull("getCodeSigners() of a primitive JarEntry should return null", new JarEntry(
-                "aaa").getCodeSigners());
+        assertNull(
+                "getCodeSigners() should be null for a primitive JarEntry",
+                new JarEntry("aaa").getCodeSigners());
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java Wed Apr  9 04:01:14 2008
@@ -38,308 +38,304 @@
 
 public class JarFileTest extends TestCase {
 
-	private final String jarName = "hyts_patch.jar"; // a 'normal' jar file
+    /**
+     * The file contains the following entries:
+     * 
+     * <pre>
+     * META-INF/ META-INF/MANIFEST.MF
+     * foo/ foo/bar/ foo/bar/A.class
+     * Blah.txt
+     * </pre>
+     */
+    private final String JAR1 = "hyts_patch.jar";
+
+    private final String JAR2 = "hyts_patch2.jar";
 
-    private final String jarName2 = "hyts_patch2.jar"; 
+    private final String JAR3 = "hyts_manifest1.jar";
 
-    private final String jarName3 = "hyts_manifest1.jar";
+    private final String JAR4 = "hyts_signed.jar";
 
-    private final String jarName4 = "hyts_signed.jar";
+    private final String JAR5 = "Integrate.jar";
 
-    private final String entryName = "foo/bar/A.class";
+    private final String JAR1_ENTRY1 = "foo/bar/A.class";
 
-    private final String entryName3 = "coucou/FileAccess.class";
+    private final String JAR5_SIGNED_ENTRY = "Test.class";
+
+    private final String JAR4_SIGNED_ENTRY = "coucou/FileAccess.class";
 
     private File resources;
-    
+
     @Override
     protected void setUp() {
         resources = Support_Resources.createTempFolder();
     }
 
-	/**
-	 * @tests java.util.jar.JarFile#JarFile(java.io.File)
-	 */
-	public void test_ConstructorLjava_io_File() {
-		// Test for method java.util.jar.JarFile(java.io.File)
-		/*
-		 * try { assertTrue("Error in created file", new JarFile(new
-		 * java.io.File(jarName)).getEntry(entryName).getName().equals(entryName)); }
-		 * catch (Exception e) { fail("Exception during test: " +
-		 * e.toString()); }
-		 */
-	}
-
-	/**
-	 * @tests java.util.jar.JarFile#JarFile(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		// Test for method java.util.jar.JarFile(java.lang.String)
-		/*
-		 * try { assertTrue("Error in created file", new
-		 * JarFile(jarName).getEntry(entryName).getName().equals(entryName)); }
-		 * catch (Exception e) { fail("Exception during test: " +
-		 * e.toString()); }
-		 */
-	}
-
-	/**
-	 * @tests java.util.jar.JarFile#entries()
-	 */
-	public void test_entries() throws Exception {
-        /*
-         * Note only (and all of) the following should be contained in the file
-         * META-INF/ META-INF/MANIFEST.MF foo/ foo/bar/ foo/bar/A.class Blah.txt
-         */
-        Support_Resources.copyFile(resources, null, jarName);
-        JarFile jarFile = new JarFile(new File(resources, jarName));
+    /**
+     * Constructs JarFile object.
+     * 
+     * @tests java.util.jar.JarFile#JarFile(java.io.File)
+     * @tests java.util.jar.JarFile#JarFile(java.lang.String)
+     */
+    public void testConstructor() throws IOException {
+        File f = new File(resources, JAR1);
+        Support_Resources.copyFile(resources, null, JAR1);
+        assertTrue(new JarFile(f).getEntry(JAR1_ENTRY1).getName().equals(
+                JAR1_ENTRY1));
+        assertTrue(new JarFile(f.getPath()).getEntry(JAR1_ENTRY1).getName()
+                .equals(JAR1_ENTRY1));
+    }
+
+    /**
+     * @tests java.util.jar.JarFile#entries()
+     */
+    public void testEntries() throws Exception {
+        Support_Resources.copyFile(resources, null, JAR1);
+        JarFile jarFile = new JarFile(new File(resources, JAR1));
         Enumeration<JarEntry> e = jarFile.entries();
-        int i = 0;
-        while (e.hasMoreElements()) {
-            i++;
+        int i;
+        for (i = 0; e.hasMoreElements(); i++) {
             e.nextElement();
         }
+        assertEquals(jarFile.size(), i);
         jarFile.close();
         assertEquals(6, i);
     }
-    
-    public void test_entries2() throws Exception {
-        Support_Resources.copyFile(resources, null, jarName);
-        JarFile jarFile = new JarFile(new File(resources, jarName));
+
+    public void testEntriesIterator() throws Exception {
+        Support_Resources.copyFile(resources, null, JAR1);
+        JarFile jarFile = new JarFile(new File(resources, JAR1));
         Enumeration<JarEntry> enumeration = jarFile.entries();
         jarFile.close();
-        boolean pass = false;
         try {
             enumeration.hasMoreElements();
+            fail("hasMoreElements() did not detect a closed jar file");
         } catch (IllegalStateException e) {
-            pass = true;
         }
-        assertTrue("hasMoreElements did not detect closed jar file", pass);
-        Support_Resources.copyFile(resources, null, jarName);
-        jarFile = new JarFile(new File(resources, jarName));
+        Support_Resources.copyFile(resources, null, JAR1);
+        jarFile = new JarFile(new File(resources, JAR1));
         enumeration = jarFile.entries();
         jarFile.close();
-        pass = false;
         try {
             enumeration.nextElement();
+            fail("nextElement() did not detect closed jar file");
         } catch (IllegalStateException e) {
-            pass = true;
         }
-        assertTrue("nextElement did not detect closed jar file", pass);
     }
 
-	/**
-	 * @tests java.util.jar.JarFile#getJarEntry(java.lang.String)
-	 */
-	public void test_getJarEntryLjava_lang_String() throws Exception {
-		Support_Resources.copyFile(resources, null, jarName);
-		JarFile jarFile = new JarFile(new File(resources, jarName));
-		assertEquals("Error in returned entry", 311, jarFile.getEntry(entryName)
-				.getSize());
-		jarFile.close();
-
-		// tests for signed jars
-		// test all signed jars in the /Testres/Internal/SignedJars directory
-		String jarDirUrl = Support_Resources
-				.getResourceURL("/../internalres/signedjars");
-		Vector<String> signedJars = new Vector<String>();
-		try {
-			InputStream is = new URL(jarDirUrl + "/jarlist.txt").openStream();
-			while (is.available() > 0) {
-				StringBuffer linebuff = new StringBuffer(80); // Typical line
-				// length
-				done: while (true) {
-					int nextByte = is.read();
-					switch (nextByte) {
-					case -1:
-						break done;
-					case (byte) '\r':
-						if (linebuff.length() == 0) {
-							// ignore
-						}
-						break done;
-					case (byte) '\n':
-						if (linebuff.length() == 0) {
-							// ignore
-						}
-						break done;
-					default:
-						linebuff.append((char) nextByte);
-					}
-				}
-				if (linebuff.length() == 0) {
-					break;
-				}
-				String line = linebuff.toString();
-				signedJars.add(line);
-			}
-			is.close();
-		} catch (IOException e) {
-			// no list of jars found
-		}
-
-		for (int i = 0; i < signedJars.size(); i++) {
-			String jarName = signedJars.get(i);
-			try {
-				File file = Support_Resources.getExternalLocalFile(jarDirUrl
-						+ "/" + jarName);
-				jarFile = new JarFile(file, true);
-				boolean foundCerts = false;
-				Enumeration<JarEntry> e = jarFile.entries();
-				while (e.hasMoreElements()) {
-					JarEntry entry = e.nextElement();
-					InputStream is = jarFile.getInputStream(entry);
-					is.skip(100000);
-					is.close();
-					Certificate[] certs = entry.getCertificates();
-					if (certs != null && certs.length > 0) {
-						foundCerts = true;
-						break;
-					}
-				}
-				assertTrue(
-						"No certificates found during signed jar test for jar \""
-								+ jarName + "\"", foundCerts);
-			} catch (IOException e) {
-				fail("Exception during signed jar test for jar \""
-						+ jarName + "\": " + e.toString());
-			}
-		}
-	}
-
-	/**
-	 * @tests java.util.jar.JarFile#getManifest()
-	 */
-	public void test_getManifest() throws Exception {
-		// Test for method java.util.jar.Manifest
-		// java.util.jar.JarFile.getManifest()
-		Support_Resources.copyFile(resources, null, jarName);
-		JarFile jarFile = new JarFile(new File(resources, jarName));
-		assertNotNull("Error--Manifest not returned",
-				jarFile.getManifest());
-		jarFile.close();
-
-		Support_Resources.copyFile(resources, null, jarName2);
-                jarFile = new JarFile(new File(resources, jarName2));
-		assertNull("Error--should have returned null", jarFile
-				.getManifest());
-		jarFile.close();
-
-		// jarName3 was created using the following test
-		Support_Resources.copyFile(resources, null, jarName3);
-		jarFile = new JarFile(new File(resources, jarName3));
-		assertNotNull("Should find manifest without verifying", jarFile
-				.getManifest());
-		jarFile.close();
-
-		// this is used to create jarName3 used in the previous test
-		Manifest manifest = new Manifest();
-		Attributes attributes = manifest.getMainAttributes();
-		attributes.put(new Attributes.Name("Manifest-Version"), "1.0");
-		ByteArrayOutputStream manOut = new ByteArrayOutputStream();
-		manifest.write(manOut);
-		byte[] manBytes = manOut.toByteArray();
-		File file = new File(Support_PlatformFile.getNewPlatformFile(
-				"hyts_manifest1", ".jar"));
-		JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(
-				file.getAbsolutePath()));
-		ZipEntry entry = new ZipEntry("META-INF/");
-		entry.setSize(0);
-		jarOut.putNextEntry(entry);
-		entry = new ZipEntry(JarFile.MANIFEST_NAME);
-		entry.setSize(manBytes.length);
-		jarOut.putNextEntry(entry);
-		jarOut.write(manBytes);
-		entry = new ZipEntry("myfile");
-		entry.setSize(1);
-		jarOut.putNextEntry(entry);
-		jarOut.write(65);
-		jarOut.close();
-		JarFile jar = new JarFile(file.getAbsolutePath(), false);
-		assertNotNull("Should find manifest without verifying", jar
-				.getManifest());
-		jar.close();
-		file.delete();
-
-                try {
-			Support_Resources.copyFile(resources, null, jarName2);
-			JarFile jF = new JarFile(new File(resources, jarName2));
-			jF.close();
-			jF.getManifest();
-		        fail("FAILED: expected IllegalStateException" ); 
-		} catch (IllegalStateException ise) {
-			//expected;
-		}
-	}
-
-	/**
-	 * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry)
-	 */
-	public void test_getInputStreamLjava_util_jar_JarEntry() throws Exception {
+    /**
+     * @tests java.util.jar.JarFile#getJarEntry(java.lang.String)
+     */
+    public void testGetJarEntry() throws Exception {
+        Support_Resources.copyFile(resources, null, JAR1);
+        JarFile jarFile = new JarFile(new File(resources, JAR1));
+        assertEquals("Error in returned entry", 311, jarFile.getEntry(
+                JAR1_ENTRY1).getSize());
+        jarFile.close();
+
+        // tests for signed jars
+        // test all signed jars in the /Testres/Internal/SignedJars directory
+        String jarDirUrl = Support_Resources
+                .getResourceURL("/../internalres/signedjars");
+        Vector<String> signedJars = new Vector<String>();
+        try {
+            InputStream is = new URL(jarDirUrl + "/jarlist.txt").openStream();
+            while (is.available() > 0) {
+                StringBuffer linebuff = new StringBuffer(80); // Typical line
+                // length
+                done: while (true) {
+                    int nextByte = is.read();
+                    switch (nextByte) {
+                    case -1:
+                        break done;
+                    case (byte) '\r':
+                        if (linebuff.length() == 0) {
+                            // ignore
+                        }
+                        break done;
+                    case (byte) '\n':
+                        if (linebuff.length() == 0) {
+                            // ignore
+                        }
+                        break done;
+                    default:
+                        linebuff.append((char) nextByte);
+                    }
+                }
+                if (linebuff.length() == 0) {
+                    break;
+                }
+                String line = linebuff.toString();
+                signedJars.add(line);
+            }
+            is.close();
+        } catch (IOException e) {
+            // no list of jars found
+        }
+
+        for (int i = 0; i < signedJars.size(); i++) {
+            String jarName = signedJars.get(i);
+            try {
+                File file = Support_Resources.getExternalLocalFile(jarDirUrl
+                        + "/" + jarName);
+                jarFile = new JarFile(file, true);
+                boolean foundCerts = false;
+                Enumeration<JarEntry> e = jarFile.entries();
+                while (e.hasMoreElements()) {
+                    JarEntry entry = e.nextElement();
+                    InputStream is = jarFile.getInputStream(entry);
+                    is.skip(100000);
+                    is.close();
+                    Certificate[] certs = entry.getCertificates();
+                    if (certs != null && certs.length > 0) {
+                        foundCerts = true;
+                        break;
+                    }
+                }
+                assertTrue(
+                        "No certificates found during signed jar test for jar \""
+                                + jarName + "\"", foundCerts);
+            } catch (IOException e) {
+                fail("Exception during signed jar test for jar \"" + jarName
+                        + "\": " + e.toString());
+            }
+        }
+    }
+
+    /**
+     * @tests java.util.jar.JarFile#getManifest()
+     */
+    public void testGetManifest() throws Exception {
+        // Test for method java.util.jar.Manifest
+        // java.util.jar.JarFile.getManifest()
+        Support_Resources.copyFile(resources, null, JAR1);
+        JarFile jarFile = new JarFile(new File(resources, JAR1));
+        assertNotNull("Error--Manifest not returned", jarFile.getManifest());
+        jarFile.close();
+
+        Support_Resources.copyFile(resources, null, JAR2);
+        jarFile = new JarFile(new File(resources, JAR2));
+        assertNull("Error--should have returned null", jarFile.getManifest());
+        jarFile.close();
+
+        // jarName3 was created using the following test
+        Support_Resources.copyFile(resources, null, JAR3);
+        jarFile = new JarFile(new File(resources, JAR3));
+        assertNotNull("Should find manifest without verifying", jarFile
+                .getManifest());
+        jarFile.close();
+
+        // this is used to create jarName3 used in the previous test
+        Manifest manifest = new Manifest();
+        Attributes attributes = manifest.getMainAttributes();
+        attributes.put(new Attributes.Name("Manifest-Version"), "1.0");
+        ByteArrayOutputStream manOut = new ByteArrayOutputStream();
+        manifest.write(manOut);
+        byte[] manBytes = manOut.toByteArray();
+        File file = new File(Support_PlatformFile.getNewPlatformFile(
+                "hyts_manifest1", ".jar"));
+        JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(file
+                .getAbsolutePath()));
+        ZipEntry entry = new ZipEntry("META-INF/");
+        entry.setSize(0);
+        jarOut.putNextEntry(entry);
+        entry = new ZipEntry(JarFile.MANIFEST_NAME);
+        entry.setSize(manBytes.length);
+        jarOut.putNextEntry(entry);
+        jarOut.write(manBytes);
+        entry = new ZipEntry("myfile");
+        entry.setSize(1);
+        jarOut.putNextEntry(entry);
+        jarOut.write(65);
+        jarOut.close();
+        JarFile jar = new JarFile(file.getAbsolutePath(), false);
+        assertNotNull("Should find manifest without verifying", jar
+                .getManifest());
+        jar.close();
+        file.delete();
+
+        try {
+            Support_Resources.copyFile(resources, null, JAR2);
+            JarFile jF = new JarFile(new File(resources, JAR2));
+            jF.close();
+            jF.getManifest();
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException ise) {
+            // expected;
+        }
+    }
+
+    /**
+     * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry)
+     */
+    public void testGetInputStream() throws Exception {
         File localFile;
         byte[] b = new byte[1024];
         JarFile jf;
         InputStream is;
 
-        Support_Resources.copyFile(resources, null, jarName);
-        localFile = new File(resources, jarName);
+        Support_Resources.copyFile(resources, null, JAR1);
+        localFile = new File(resources, JAR1);
 
         jf = new JarFile(localFile);
 
         is = jf.getInputStream(new JarEntry("invalid"));
         assertNull("Got stream for non-existent entry", is);
 
-        is = jf.getInputStream(jf.getEntry(entryName));
+        is = jf.getInputStream(jf.getEntry(JAR1_ENTRY1));
         assertTrue("Returned invalid stream", is.available() > 0);
 
         // try to read class file header
         is.read(b, 0, 1024);
         jf.close();
-        assertTrue("Invalid bytes were red",
-                b[0] == (byte) 0xCA &&
-                b[1] == (byte) 0xFE &&
-                b[2] == (byte) 0xBA &&
-                b[3] == (byte) 0xBE);
-    }
-
-	/**
-	 * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry)
-	 */
-	public void test_getInputStreamLjava_util_jar_JarEntry_subtest0() throws Exception {
-		File signedFile = null;
-		Support_Resources.copyFile(resources, null, jarName4);
-		signedFile = new File(resources, jarName4);
-
-		JarFile jar = new JarFile(signedFile);
-		JarEntry entry = new JarEntry(entryName3);
-		InputStream in = jar.getInputStream(entry);
-		in.read();
-
-                jar = new JarFile(signedFile);
-		entry = new JarEntry(entryName3);
-		in = jar.getInputStream(entry);
-		in.read(new byte[1077]);
-		assertNull("found certificates", entry.getCertificates());
-
-		boolean exception = false;
-		try {
-			jar = new JarFile(signedFile);
-			entry = new JarEntry(entryName3);
-			entry.setSize(1076);
-			in = jar.getInputStream(entry);
-			in.read(new byte[2048]);
-		} catch (SecurityException e) {
-			exception = true;
-		}
+        assertTrue("Invalid bytes were red", b[0] == (byte) 0xCA
+                && b[1] == (byte) 0xFE && b[2] == (byte) 0xBA
+                && b[3] == (byte) 0xBE);
+    }
 
-		assertTrue("Failed to throw SecurityException", exception);
-	}
+    /**
+     * Signed file is verified by default.
+     * 
+     * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry)
+     */
+    public void testInputStreamOperations() throws Exception {
+        Support_Resources.copyFile(resources, null, JAR4);
+        File signedFile = new File(resources, JAR4);
+
+        JarFile jar = new JarFile(signedFile);
+        JarEntry entry = new JarEntry(JAR4_SIGNED_ENTRY);
+        InputStream in = jar.getInputStream(entry);
+        in.read();
+
+        // RI verifies only entries which appear via getJarEntry method
+        jar = new JarFile(signedFile);
+        entry = jar.getJarEntry(JAR4_SIGNED_ENTRY);
+        in = jar.getInputStream(entry);
+        in.read(new byte[(int) entry.getSize() - 1]);
+        assertNull(entry.getCertificates());
+        in.read();
+        assertNotNull(entry.getCertificates());
+        assertEquals(-1, in.read());
+
+        jar = new JarFile(signedFile);
+        entry = jar.getJarEntry(JAR4_SIGNED_ENTRY);
+        entry.setSize(entry.getSize() - 1);
+        in = jar.getInputStream(entry);
+        in.read(new byte[(int) entry.getSize() - 1]);
+        assertNull(entry.getCertificates());
+        try {
+            in.read();
+            fail("SecurityException expected");
+        } catch (SecurityException e) {
+            // desired
+        }
+        assertEquals(-1, in.read());
+    }
 
     /*
      * The jar created by 1.4 which does not provide a
      * algorithm-Digest-Manifest-Main-Attributes entry in .SF file.
      */
-    public void test_Jar_created_before_java_5() throws IOException {
+    public void testJar14() throws IOException {
         String modifiedJarName = "Created_by_1_4.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
@@ -351,16 +347,40 @@
         }
     }
 
-    /* The jar is intact, then everything is all right. */
-    public void test_JarFile_Integrate_Jar() throws IOException {
-        String modifiedJarName = "Integrate.jar";
-        Support_Resources.copyFile(resources, null, modifiedJarName);
-        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
-                true);
+    /**
+     * The jar is intact, then everything is all right.
+     */
+    public void testJarVerification() throws IOException {
+        Support_Resources.copyFile(resources, null, JAR5);
+        JarFile jarFile = new JarFile(new File(resources, JAR5), true);
         Enumeration<JarEntry> entries = jarFile.entries();
         while (entries.hasMoreElements()) {
             ZipEntry zipEntry = entries.nextElement();
-            jarFile.getInputStream(zipEntry);
+            jarFile.getInputStream(zipEntry).skip(Long.MAX_VALUE);
+        }
+    }
+
+    /**
+     * The jar is intact, but the entry object is modified.
+     */
+    public void testJarVerificationModifiedEntry() throws IOException {
+        Support_Resources.copyFile(resources, null, JAR5);
+        File f = new File(resources, JAR5);
+
+        JarFile jarFile = new JarFile(f);
+        ZipEntry zipEntry = jarFile.getJarEntry(JAR5_SIGNED_ENTRY);
+        zipEntry.setSize(zipEntry.getSize() + 1);
+        jarFile.getInputStream(zipEntry).skip(Long.MAX_VALUE);
+
+        jarFile = new JarFile(f);
+        zipEntry = jarFile.getJarEntry(JAR5_SIGNED_ENTRY);
+        zipEntry.setSize(zipEntry.getSize() - 1);
+        try {
+            //jarFile.getInputStream(zipEntry).skip(Long.MAX_VALUE);
+            jarFile.getInputStream(zipEntry).read(new byte[5000], 0, 5000);
+            fail("SecurityException expected");
+        } catch (SecurityException e) {
+            // desired
         }
     }
 
@@ -368,7 +388,7 @@
      * If another entry is inserted into Manifest, no security exception will be
      * thrown out.
      */
-    public void test_JarFile_InsertEntry_in_Manifest_Jar() throws IOException {
+    public void testJarFileInsertEntryInManifestJar() throws IOException {
         String modifiedJarName = "Inserted_Entry_Manifest.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
@@ -388,8 +408,7 @@
      * If another entry is inserted into Manifest, no security exception will be
      * thrown out.
      */
-    public void test_Inserted_Entry_Manifest_with_DigestCode()
-            throws IOException {
+    public void testInsertedEntryManifestWithDigestCode() throws IOException {
         String modifiedJarName = "Inserted_Entry_Manifest_with_DigestCode.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
@@ -397,7 +416,6 @@
         Enumeration<JarEntry> entries = jarFile.entries();
         int count = 0;
         while (entries.hasMoreElements()) {
-
             ZipEntry zipEntry = entries.nextElement();
             jarFile.getInputStream(zipEntry);
             count++;
@@ -410,7 +428,7 @@
      * throw security Exception, but it will anytime before the inputStream got
      * from getInputStream method has been read to end.
      */
-    public void test_JarFile_Modified_Class() throws IOException {
+    public void testJarFileModifiedClass() throws IOException {
         String modifiedJarName = "Modified_Class.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
@@ -428,7 +446,7 @@
             while (in.available() > 0) {
                 in.read(buffer);
             }
-            fail("should throw Security Exception");
+            fail("SecurityException expected");
         } catch (SecurityException e) {
             // desired
         }
@@ -437,10 +455,9 @@
     /*
      * In the Modified.jar, the main attributes of META-INF/MANIFEST.MF is
      * tampered manually. Hence the RI 5.0 JarFile.getInputStream of any
-     * JarEntry will throw security exception, but the apache harmony will not.
+     * JarEntry will throw security exception.
      */
-    public void test_JarFile_Modified_Manifest_MainAttributes()
-            throws IOException {
+    public void testJarFileModifiedManifestMainAttributes() throws IOException {
         String modifiedJarName = "Modified_Manifest_MainAttributes.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
@@ -450,7 +467,7 @@
             ZipEntry zipEntry = entries.nextElement();
             try {
                 jarFile.getInputStream(zipEntry);
-                fail("should throw Security Exception");
+                fail("SecurityException expected");
             } catch (SecurityException e) {
                 // desired
             }
@@ -462,8 +479,7 @@
      * example Test.class in our jar, the jarFile.getInputStream will throw
      * Security Exception.
      */
-    public void test_JarFile_Modified_Manifest_EntryAttributes()
-            throws IOException {
+    public void testJarFileModifiedManifestEntryAttributes() throws IOException {
         String modifiedJarName = "Modified_Manifest_EntryAttributes.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
@@ -484,7 +500,7 @@
      * If the content of the .SA file is modified, no matter what it resides,
      * JarFile.getInputStream of any JarEntry will throw Security Exception.
      */
-    public void test_JarFile_Modified_SF_EntryAttributes() throws IOException {
+    public void testJarFileModifiedSfEntryAttributes() throws IOException {
         String modifiedJarName = "Modified_SF_EntryAttributes.jar";
         Support_Resources.copyFile(resources, null, modifiedJarName);
         JarFile jarFile = new JarFile(new File(resources, modifiedJarName),

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java Wed Apr  9 04:01:14 2008
@@ -17,6 +17,7 @@
 package org.apache.harmony.archive.tests.java.util.jar;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,222 +28,404 @@
 import java.util.jar.Manifest;
 
 import junit.framework.TestCase;
+
 import tests.support.resource.Support_Resources;
 
 public class ManifestTest extends TestCase {
 
-	private final String JAR_NAME = "hyts_patch.jar";
+    private final String JAR_NAME = "hyts_patch.jar";
 
     private final String ATT_JAR_NAME = "hyts_att.jar";
 
-    private final String MANIFEST_NAME = "manifest/hyts_MANIFEST.MF";
+    private final String ATT_ENTRY_NAME = "HasAttributes.txt";
 
-    private Manifest m;
-    
-    private Manifest m2;
+    private final String ATT_ATT_NAME = "MyAttribute";
+
+    private final String MANIFEST_NAME = "manifest/hyts_MANIFEST.MF";
 
     private File resources;
-    
+
     @Override
     protected void setUp() {
         resources = Support_Resources.createTempFolder();
+    }
+
+    private Manifest getManifest(String fileName) {
         try {
-            Support_Resources.copyFile(resources, null, JAR_NAME);
-            JarFile jarFile = new JarFile(new File(resources, JAR_NAME));
-            m = jarFile.getManifest();
-            jarFile.close();
-            Support_Resources.copyFile(resources, null, ATT_JAR_NAME);
-            jarFile = new JarFile(new File(resources, ATT_JAR_NAME));
-            m2 = jarFile.getManifest();
+            Support_Resources.copyFile(resources, null, fileName);
+            JarFile jarFile = new JarFile(new File(resources, fileName));
+            Manifest m = jarFile.getManifest();
             jarFile.close();
+            return m;
         } catch (Exception e) {
             fail("Exception during setup: " + e.toString());
+            return null;
         }
     }
 
-	/**
-	 * @tests java.util.jar.Manifest#Manifest()
-	 */
-	public void test_Constructor() {
-		// Test for method java.util.jar.Manifest()
-		Manifest emptyManifest = new Manifest();
-		assertTrue("Should have no entries", emptyManifest.getEntries()
-				.isEmpty());
-		assertTrue("Should have no main attributes", emptyManifest
-				.getMainAttributes().isEmpty());
-	}
+    /**
+     * @tests java.util.jar.Manifest#Manifest()
+     */
+    public void testConstructor() {
+        // Test for method java.util.jar.Manifest()
+        Manifest emptyManifest = new Manifest();
+        assertTrue("Should have no entries", emptyManifest.getEntries()
+                .isEmpty());
+        assertTrue("Should have no main attributes", emptyManifest
+                .getMainAttributes().isEmpty());
+    }
 
     /**
      * @tests java.util.jar.Manifest#Manifest(java.util.jar.Manifest)
      */
-    public void test_Constructor_Ljava_util_jar_Manifest() throws IOException {
+    public void testCopyingConstructor() throws IOException {
         Manifest firstManifest = new Manifest(new URL(Support_Resources
                 .getURL(MANIFEST_NAME)).openStream());
         Manifest secondManifest = new Manifest(firstManifest);
         assertEquals(firstManifest, secondManifest);
     }
-	
-	/**
-	 * @tests java.util.jar.Manifest#Manifest(java.io.InputStream)
-	 */
-	public void test_ConstructorLjava_io_InputStream() throws IOException {
-		// Test for method java.util.jar.Manifest(java.io.InputStream)
-		/*
-		 * ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		 * m2.write(baos); InputSteam is = new ByteArrayInputStream
-		 * (baos.toByteArray()); Manifest myManifest = new Manifest (is);
-		 * assertTrue("Manifests should be equal", myManifest.equals(m2));
-		 */
+
+    private void assertAttribute(Attributes attr, String name, String value) {
+        assertEquals("Incorrect " + name, value, attr.getValue(name));
+    }
+
+    private void checkManifest(Manifest manifest) {
+        Attributes main = manifest.getMainAttributes();
+        assertAttribute(main, "Bundle-Name", "ClientSupport");
+        assertAttribute(main, "Bundle-Description",
+                "Provides SessionService, AuthenticationService. Extends RegistryService.");
+        assertAttribute(main, "Bundle-Activator",
+                "com.ibm.ive.eccomm.client.support.ClientSupportActivator");
+        assertAttribute(
+                main,
+                "Import-Package",
+                "com.ibm.ive.eccomm.client.services.log,com.ibm.ive.eccomm.client.services.registry,com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,com.ibm.ive.eccomm.service.session; specification-version=1.0.0,com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,org.osgi.framework; specification-version=1.0.0,org.osgi.service.log; specification-version=1.0.0,com.ibm.ive.eccomm.flash; specification-version=1.2.0,com.ibm.ive.eccomm.client.xml,com.ibm.ive.eccomm.client.http.common,com.ibm.ive.eccomm.client.http.client");
+        assertAttribute(
+                main,
+                "Import-Service",
+                "org.osgi.service.log.LogReaderServiceorg.osgi.service.log.LogService,com.ibm.ive.eccomm.service.registry.RegistryService");
+        assertAttribute(
+                main,
+                "Export-Package",
+                "com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.common; specification-version=1.0.0,com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0");
+        assertAttribute(
+                main,
+                "Export-Service",
+                "com.ibm.ive.eccomm.service.authentication.AuthenticationService,com.ibm.ive.eccomm.service.session.SessionService");
+        assertAttribute(main, "Bundle-Vendor", "IBM");
+        assertAttribute(main, "Bundle-Version", "1.2.0");
+    }
+
+    /**
+     * @tests java.util.jar.Manifest#Manifest(java.io.InputStream)
+     */
+    public void testStreamConstructor() throws IOException {
+        Manifest m = getManifest(ATT_JAR_NAME);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        m.write(baos);
+        InputStream is = new ByteArrayInputStream(baos.toByteArray());
+        Manifest mCopy = new Manifest(is);
+        assertEquals(m, mCopy);
 
         Manifest manifest = new Manifest(new URL(Support_Resources
                 .getURL(MANIFEST_NAME)).openStream());
+        checkManifest(manifest);
 
-		Attributes main = manifest.getMainAttributes();
-		assertEquals("Bundle-Name not correct", "ClientSupport", main.getValue("Bundle-Name")
-				);
-		assertEquals("Bundle-Description not correct",
-				
-								"Provides SessionService, AuthenticationService. Extends RegistryService.", main
-						.getValue("Bundle-Description")
-						);
-		assertEquals("Bundle-Activator not correct", 
-				"com.ibm.ive.eccomm.client.support.ClientSupportActivator", main.getValue(
-				"Bundle-Activator"));
-		assertEquals("Import-Package not correct",
-				
-								"com.ibm.ive.eccomm.client.services.log,com.ibm.ive.eccomm.client.services.registry,com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,com.ibm.ive.eccomm.service.session; specification-version=1.0.0,com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,org.osgi.framework; specification-version=1.0.0,org.osgi.service.log; specification-version=1.0.0,com.ibm.ive.eccomm.flash; specification-version=1.2.0,com.ibm.ive.eccomm.client.xml,com.ibm.ive.eccomm.client.http.common,com.ibm.ive.eccomm.client.http.client", main
-						.getValue("Import-Package")
-						);
-		assertEquals("Import-Service not correct",
-				
-								"org.osgi.service.log.LogReaderServiceorg.osgi.service.log.LogService,com.ibm.ive.eccomm.service.registry.RegistryService", main
-						.getValue("Import-Service")
-						);
-		assertEquals("Export-Package not correct",
-				
-								"com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.common; specification-version=1.0.0,com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0", main
-						.getValue("Export-Package")
-						);
-		assertEquals("Export-Service not correct",
-				
-								"com.ibm.ive.eccomm.service.authentication.AuthenticationService,com.ibm.ive.eccomm.service.session.SessionService", main
-						.getValue("Export-Service")
-						);
-		assertEquals("Bundle-Vendor not correct", "IBM", main.getValue("Bundle-Vendor")
-				);
-		assertEquals("Bundle-Version not correct", "1.2.0", main
-				.getValue("Bundle-Version"));
-
-        // Regression test for HARMONY-5424
+        // regression test for HARMONY-5424
         String manifestContent = "Manifest-Version: 1.0\nCreated-By: Apache\nPackage: \nBuild-Jdk: 1.4.1_01\n\n"
                 + "Name: \nSpecification-Title: foo\nSpecification-Version: 1.0\nSpecification-Vendor: \n"
                 + "Implementation-Title: \nImplementation-Version: 1.0\nImplementation-Vendor: \n\n";
         ByteArrayInputStream bis = new ByteArrayInputStream(manifestContent
-                .getBytes());
-        Manifest mf = new Manifest(bis);
+                .getBytes("ISO-8859-1"));
+
 
-        assertEquals("Wrong number of main attributes", 4, mf
-                .getMainAttributes().size());
+        Manifest mf = new Manifest(bis);
+        assertEquals("Should be 4 main attributes", 4, mf.getMainAttributes()
+                .size());
 
         Map<String, Attributes> entries = mf.getEntries();
-        assertEquals("Wrong number of named entries", 1, entries.size());
+        assertEquals("Should be one named entry", 1, entries.size());
 
         Attributes namedEntryAttributes = (Attributes) (entries.get(""));
-        assertEquals("Wrong number of named entry attributes", 6,
+        assertEquals("Should be 6 named entry attributes", 6,
                 namedEntryAttributes.size());
-	}
+    }
 
-	/**
-	 * @tests java.util.jar.Manifest#clear()
-	 */
-	public void test_clear() {
-		// Test for method void java.util.jar.Manifest.clear()
-		m2.clear();
-		assertTrue("Should have no entries", m2.getEntries().isEmpty());
-		assertTrue("Should have no main attributes", m2.getMainAttributes()
-				.isEmpty());
-	}
+    /**
+     * @tests java.util.jar.Manifest#clear()
+     */
+    public void testClear() {
+        Manifest m = getManifest(ATT_JAR_NAME);
+        m.clear();
+        assertTrue("Should have no entries", m.getEntries().isEmpty());
+        assertTrue("Should have no main attributes", m.getMainAttributes()
+                .isEmpty());
+    }
 
     /**
      * @tests java.util.jar.Manifest#clone()
      */
-    public void test_clone() {
-        Manifest newManifest = (Manifest) m.clone();
-        assertEquals(newManifest, m);
+    public void testClone() {
+        Manifest m = getManifest(JAR_NAME);
+        assertEquals(m, m.clone());
     }
 
     /**
      * @tests java.util.jar.Manifest#equals(java.lang.Object)
      */
-    public void test_equalsLjava_lang_Object() throws IOException {
+    public void testEquals() throws IOException {
         Manifest firstManifest = new Manifest(new URL(Support_Resources
                 .getURL(MANIFEST_NAME)).openStream());
         Manifest secondManifest = new Manifest(new URL(Support_Resources
                 .getURL(MANIFEST_NAME)).openStream());
 
-        assertTrue(firstManifest.equals(secondManifest));
+        assertEquals(firstManifest, secondManifest);
     }
 
     /**
      * @tests java.util.jar.Manifest#hashCode()
      */
-    public void test_hashCode() {
-        Manifest newManifest = (Manifest) m.clone();
-        assertEquals(newManifest.hashCode(), m.hashCode());
-    }
-	
-	/**
-	 * @tests java.util.jar.Manifest#getAttributes(java.lang.String)
-	 */
-	public void test_getAttributesLjava_lang_String() {
-		// Test for method java.util.jar.Attributes
-		// java.util.jar.Manifest.getAttributes(java.lang.String)
-		assertNull("Should not exist",
-				m2.getAttributes("Doesn't Exist"));
-		assertEquals("Should exist", "OK", m2.getAttributes("HasAttributes.txt").get(
-				new Attributes.Name("MyAttribute")));
-	}
-
-	/**
-	 * @tests java.util.jar.Manifest#getEntries()
-	 */
-	public void test_getEntries() {
-		// Test for method java.util.Map java.util.jar.Manifest.getEntries()
-		Map<String, Attributes> myMap = m2.getEntries();
-		assertNull("Shouldn't exist", myMap.get("Doesn't exist"));
-		assertEquals("Should exist",
-				"OK", myMap.get("HasAttributes.txt").get(
-						new Attributes.Name("MyAttribute")));
-
-	}
-
-	/**
-	 * @tests java.util.jar.Manifest#getMainAttributes()
-	 */
-	public void test_getMainAttributes() {
-		// Test for method java.util.jar.Attributes
-		// java.util.jar.Manifest.getMainAttributes()
-		Attributes a = m.getMainAttributes();
-		assertEquals("Manifest_Version should return 1.0", "1.0", a.get(
-				Attributes.Name.MANIFEST_VERSION));
-	}
+    public void testHashCode() {
+        Manifest m = getManifest(JAR_NAME);
+        assertEquals(m.hashCode(), m.clone().hashCode());
+    }
+
+    /**
+     * @tests java.util.jar.Manifest#getAttributes(java.lang.String)
+     */
+    public void testGetAttributes() {
+        Manifest m = getManifest(ATT_JAR_NAME);
+        assertNull("Should not exist", m.getAttributes("Doesn't Exist"));
+        assertEquals("Should exist", "OK", m.getAttributes(ATT_ENTRY_NAME).get(
+                new Attributes.Name(ATT_ATT_NAME)));
+    }
+
+    /**
+     * @tests java.util.jar.Manifest#getEntries()
+     */
+    public void testGetEntries() {
+        Manifest m = getManifest(ATT_JAR_NAME);
+        Map<String, Attributes> myMap = m.getEntries();
+        assertNull("Shouldn't exist", myMap.get("Doesn't exist"));
+        assertEquals("Should exist", "OK", myMap.get(ATT_ENTRY_NAME).get(
+                new Attributes.Name(ATT_ATT_NAME)));
+    }
+
+    /**
+     * @tests java.util.jar.Manifest#getMainAttributes()
+     */
+    public void testGetMainAttributes() {
+        Manifest m = getManifest(JAR_NAME);
+        Attributes a = m.getMainAttributes();
+        assertEquals("Manifest_Version should return 1.0", "1.0", a
+                .get(Attributes.Name.MANIFEST_VERSION));
+    }
+
+    /**
+     * @tests {@link java.util.jar.Manifest#write(java.io.OutputStream)
+     */
+    public void testWrite() throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        Manifest m = getManifest(JAR_NAME);
+        // maximum allowed length is 72 for a header, colon and a following
+        // space
+        StringBuffer headerName = new StringBuffer(71);
+        headerName.append("Manifest-");
+        while (headerName.length() < 70) {
+            headerName.append("0");
+        }
+        m.getMainAttributes().put(new Attributes.Name(headerName.toString()),
+                "Value");
+        m.write(baos); // ok
+    }
+
+    /**
+     * Ensures compatibility with manifests produced by gcc.
+     * 
+     * @see <a
+     *      href="http://issues.apache.org/jira/browse/HARMONY-5662">HARMONY-5662</a>
+     */
+    public void testNul() throws IOException {
+        String manifestContent =
+                "Manifest-Version: 1.0\nCreated-By: nasty gcc tool\n\n\0";
+
+        byte[] bytes = manifestContent.getBytes("ISO-8859-1");
+        new Manifest(new ByteArrayInputStream(bytes)); // the last NUL is ok
+        
+        bytes[bytes.length - 1] = 26;
+        new Manifest(new ByteArrayInputStream(bytes)); // the last EOF is ok
+
+        bytes[bytes.length - 1] = 'A'; // the last line ignored
+        new Manifest(new ByteArrayInputStream(bytes));
+
+        bytes[2] = 0; // NUL char in Manifest
+        try {
+            new Manifest(new ByteArrayInputStream(bytes));
+            fail("IOException expected");
+        } catch (IOException e) {
+            // desired
+        }
+    }
+
+    public void testDecoding() throws IOException {
+        Manifest m = getManifest(ATT_JAR_NAME);
+        final byte[] bVendor = new byte[] { (byte) 0xd0, (byte) 0x9C,
+                (byte) 0xd0, (byte) 0xb8, (byte) 0xd0, (byte) 0xbb,
+                (byte) 0xd0, (byte) 0xb0, (byte) 0xd1, (byte) 0x8f, ' ',
+                (byte) 0xd0, (byte) 0xb4, (byte) 0xd0, (byte) 0xbe,
+                (byte) 0xd1, (byte) 0x87, (byte) 0xd1, (byte) 0x83,
+                (byte) 0xd0, (byte) 0xbd, (byte) 0xd1, (byte) 0x8C,
+                (byte) 0xd0, (byte) 0xba, (byte) 0xd0, (byte) 0xb0, ' ',
+                (byte) 0xd0, (byte) 0x9C, (byte) 0xd0, (byte) 0xb0,
+                (byte) 0xd1, (byte) 0x88, (byte) 0xd0, (byte) 0xb0 };
+
+        final byte[] bSpec = new byte[] { (byte) 0xe1, (byte) 0x88,
+                (byte) 0xb0, (byte) 0xe1, (byte) 0x88, (byte) 0x8b,
+                (byte) 0xe1, (byte) 0x88, (byte) 0x9d, ' ', (byte) 0xe1,
+                (byte) 0x9a, (byte) 0xa0, (byte) 0xe1, (byte) 0x9a,
+                (byte) 0xb1, (byte) 0xe1, (byte) 0x9b, (byte) 0x81,
+                (byte) 0xe1, (byte) 0x9a, (byte) 0xa6, ' ', (byte) 0xd8,
+                (byte) 0xb3, (byte) 0xd9, (byte) 0x84, (byte) 0xd8,
+                (byte) 0xa7, (byte) 0xd9, (byte) 0x85, ' ', (byte) 0xd8,
+                (byte) 0xb9, (byte) 0xd8, (byte) 0xb3, (byte) 0xd9,
+                (byte) 0x84, (byte) 0xd8, (byte) 0xa7, (byte) 0xd9,
+                (byte) 0x85, (byte) 0xd8, (byte) 0xa9, ' ', (byte) 0xdc,
+                (byte) 0xab, (byte) 0xdc, (byte) 0xa0, (byte) 0xdc,
+                (byte) 0xa1, (byte) 0xdc, (byte) 0x90, ' ', (byte) 0xe0,
+                (byte) 0xa6, (byte) 0xb6, (byte) 0xe0, (byte) 0xa6,
+                (byte) 0xbe, (byte) 0xe0, (byte) 0xa6, (byte) 0xa8,
+                (byte) 0xe0, (byte) 0xa7, (byte) 0x8d, (byte) 0xe0,
+                (byte) 0xa6, (byte) 0xa4, (byte) 0xe0, (byte) 0xa6,
+                (byte) 0xbf, ' ', (byte) 0xd0, (byte) 0xa0, (byte) 0xd0,
+                (byte) 0xb5, (byte) 0xd0, (byte) 0xba, (byte) 0xd1,
+                (byte) 0x8a, (byte) 0xd0, (byte) 0xb5, (byte) 0xd0,
+                (byte) 0xbb, ' ', (byte) 0xd0, (byte) 0x9c, (byte) 0xd0,
+                (byte) 0xb8, (byte) 0xd1, (byte) 0x80, ' ', (byte) 0xe0,
+                (byte) 0xa6, (byte) 0xb6, (byte) 0xe0, (byte) 0xa6,
+                (byte) 0xbe, (byte) 0xe0, (byte) 0xa6, (byte) 0xa8,
+                (byte) 0xe0, (byte) 0xa7, (byte) 0x8d, (byte) 0xe0,
+                (byte) 0xa6, (byte) 0xa4, (byte) 0xe0, (byte) 0xa6,
+                (byte) 0xbf, ' ', (byte) 0xe0, (byte) 0xbd, (byte) 0x9e,
+                (byte) 0xe0, (byte) 0xbd, (byte) 0xb2, (byte) 0xe0,
+                (byte) 0xbc, (byte) 0x8b, (byte) 0xe0, (byte) 0xbd,
+                (byte) 0x96, (byte) 0xe0, (byte) 0xbd, (byte) 0x91,
+                (byte) 0xe0, (byte) 0xbd, (byte) 0xba, ' ', (byte) 0xd0,
+                (byte) 0x9c, (byte) 0xd0, (byte) 0xb0, (byte) 0xd1,
+                (byte) 0x88, (byte) 0xd0, (byte) 0xb0, (byte) 0xd1,
+                (byte) 0x80, ' ', (byte) 0xe1, (byte) 0x8f, (byte) 0x99,
+                (byte) 0xe1, (byte) 0x8e, (byte) 0xaf, (byte) 0xe1,
+                (byte) 0x8f, (byte) 0xb1, ' ', (byte) 0xcf, (byte) 0xa8,
+                (byte) 0xce, (byte) 0xb9, (byte) 0xcf, (byte) 0x81,
+                (byte) 0xce, (byte) 0xb7, (byte) 0xce, (byte) 0xbd,
+                (byte) 0xce, (byte) 0xb7, ' ', (byte) 0xde, (byte) 0x90,
+                (byte) 0xde, (byte) 0xaa, (byte) 0xde, (byte) 0x85,
+                (byte) 0xde, (byte) 0xa6, ' ', (byte) 0xe0, (byte) 0xbd,
+                (byte) 0x82, (byte) 0xe0, (byte) 0xbd, (byte) 0x9e,
+                (byte) 0xe0, (byte) 0xbd, (byte) 0xb2, (byte) 0xe0,
+                (byte) 0xbc, (byte) 0x8b, (byte) 0xe0, (byte) 0xbd,
+                (byte) 0x96, (byte) 0xe0, (byte) 0xbd, (byte) 0x91,
+                (byte) 0xe0, (byte) 0xbd, (byte) 0xba, ' ', (byte) 0xce,
+                (byte) 0x95, (byte) 0xce, (byte) 0xb9, (byte) 0xcf,
+                (byte) 0x81, (byte) 0xce, (byte) 0xae, (byte) 0xce,
+                (byte) 0xbd, (byte) 0xce, (byte) 0xb7, ' ', (byte) 0xd8,
+                (byte) 0xb5, (byte) 0xd9, (byte) 0x84, (byte) 0xd8,
+                (byte) 0xad, ' ', (byte) 0xe0, (byte) 0xaa, (byte) 0xb6,
+                (byte) 0xe0, (byte) 0xaa, (byte) 0xbe, (byte) 0xe0,
+                (byte) 0xaa, (byte) 0x82, (byte) 0xe0, (byte) 0xaa,
+                (byte) 0xa4, (byte) 0xe0, (byte) 0xaa, (byte) 0xbf, ' ',
+                (byte) 0xe5, (byte) 0xb9, (byte) 0xb3, (byte) 0xe5,
+                (byte) 0x92, (byte) 0x8c, ' ', (byte) 0xd7, (byte) 0xa9,
+                (byte) 0xd7, (byte) 0x9c, (byte) 0xd7, (byte) 0x95,
+                (byte) 0xd7, (byte) 0x9d, ' ', (byte) 0xd7, (byte) 0xa4,
+                (byte) 0xd7, (byte) 0xa8, (byte) 0xd7, (byte) 0x99,
+                (byte) 0xd7, (byte) 0x93, (byte) 0xd7, (byte) 0x9f, ' ',
+                (byte) 0xe5, (byte) 0x92, (byte) 0x8c, (byte) 0xe5,
+                (byte) 0xb9, (byte) 0xb3, ' ', (byte) 0xe5, (byte) 0x92,
+                (byte) 0x8c, (byte) 0xe5, (byte) 0xb9, (byte) 0xb3, ' ',
+                (byte) 0xd8, (byte) 0xaa, (byte) 0xd9, (byte) 0x89,
+                (byte) 0xd9, (byte) 0x86, (byte) 0xda, (byte) 0x86,
+                (byte) 0xd9, (byte) 0x84, (byte) 0xd9, (byte) 0x89,
+                (byte) 0xd9, (byte) 0x82, ' ', (byte) 0xe0, (byte) 0xae,
+                (byte) 0x85, (byte) 0xe0, (byte) 0xae, (byte) 0xae,
+                (byte) 0xe0, (byte) 0xaf, (byte) 0x88, (byte) 0xe0,
+                (byte) 0xae, (byte) 0xa4, (byte) 0xe0, (byte) 0xae,
+                (byte) 0xbf, ' ', (byte) 0xe0, (byte) 0xb0, (byte) 0xb6,
+                (byte) 0xe0, (byte) 0xb0, (byte) 0xbe, (byte) 0xe0,
+                (byte) 0xb0, (byte) 0x82, (byte) 0xe0, (byte) 0xb0,
+                (byte) 0xa4, (byte) 0xe0, (byte) 0xb0, (byte) 0xbf, ' ',
+                (byte) 0xe0, (byte) 0xb8, (byte) 0xaa, (byte) 0xe0,
+                (byte) 0xb8, (byte) 0xb1, (byte) 0xe0, (byte) 0xb8,
+                (byte) 0x99, (byte) 0xe0, (byte) 0xb8, (byte) 0x95,
+                (byte) 0xe0, (byte) 0xb8, (byte) 0xb4, (byte) 0xe0,
+                (byte) 0xb8, (byte) 0xa0, (byte) 0xe0, (byte) 0xb8,
+                (byte) 0xb2, (byte) 0xe0, (byte) 0xb8, (byte) 0x9e, ' ',
+                (byte) 0xe1, (byte) 0x88, (byte) 0xb0, (byte) 0xe1,
+                (byte) 0x88, (byte) 0x8b, (byte) 0xe1, (byte) 0x88,
+                (byte) 0x9d, ' ', (byte) 0xe0, (byte) 0xb7, (byte) 0x83,
+                (byte) 0xe0, (byte) 0xb7, (byte) 0x8f, (byte) 0xe0,
+                (byte) 0xb6, (byte) 0xb8, (byte) 0xe0, (byte) 0xb6,
+                (byte) 0xba, ' ', (byte) 0xe0, (byte) 0xa4, (byte) 0xb6,
+                (byte) 0xe0, (byte) 0xa4, (byte) 0xbe, (byte) 0xe0,
+                (byte) 0xa4, (byte) 0xa8, (byte) 0xe0, (byte) 0xa5,
+                (byte) 0x8d, (byte) 0xe0, (byte) 0xa4, (byte) 0xa4,
+                (byte) 0xe0, (byte) 0xa4, (byte) 0xbf, (byte) 0xe0,
+                (byte) 0xa4, (byte) 0x83, ' ', (byte) 0xe1, (byte) 0x83,
+                (byte) 0x9b, (byte) 0xe1, (byte) 0x83, (byte) 0xa8,
+                (byte) 0xe1, (byte) 0x83, (byte) 0x95, (byte) 0xe1,
+                (byte) 0x83, (byte) 0x98, (byte) 0xe1, (byte) 0x83,
+                (byte) 0x93, (byte) 0xe1, (byte) 0x83, (byte) 0x9d,
+                (byte) 0xe1, (byte) 0x83, (byte) 0x91, (byte) 0xe1,
+                (byte) 0x83, (byte) 0x90 };
+        // TODO Cannot make the following word work, encoder changes needed
+        // (byte) 0xed, (byte) 0xa0, (byte) 0x80,
+        // (byte) 0xed, (byte) 0xbc, (byte) 0xb2, (byte) 0xed,
+        // (byte) 0xa0, (byte) 0x80, (byte) 0xed, (byte) 0xbc,
+        // (byte) 0xb0, (byte) 0xed, (byte) 0xa0, (byte) 0x80,
+        // (byte) 0xed, (byte) 0xbd, (byte) 0x85, (byte) 0xed,
+        // (byte) 0xa0, (byte) 0x80, (byte) 0xed, (byte) 0xbc,
+        // (byte) 0xb0, (byte) 0xed, (byte) 0xa0, (byte) 0x80,
+        // (byte) 0xed, (byte) 0xbc, (byte) 0xb9, (byte) 0xed,
+        // (byte) 0xa0, (byte) 0x80, (byte) 0xed, (byte) 0xbc,
+        // (byte) 0xb8, (byte) 0xed, (byte) 0xa0, (byte) 0x80,
+        // (byte) 0xed, (byte) 0xbc, (byte) 0xb9, ' '
+
+        final String vendor = new String(bVendor, "UTF-8");
+        final String spec = new String(bSpec, "UTF-8");
+        m.getMainAttributes()
+                .put(Attributes.Name.IMPLEMENTATION_VENDOR, vendor);
+        m.getAttributes(ATT_ENTRY_NAME).put(
+                Attributes.Name.IMPLEMENTATION_VENDOR, vendor);
+        m.getEntries().get(ATT_ENTRY_NAME).put(
+                Attributes.Name.SPECIFICATION_TITLE, spec);
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        m.write(baos);
+        m = new Manifest(new ByteArrayInputStream(baos.toByteArray()));
+
+        assertEquals(vendor, m.getMainAttributes().get(
+                Attributes.Name.IMPLEMENTATION_VENDOR));
+        assertEquals(vendor, m.getEntries().get(ATT_ENTRY_NAME).get(
+                Attributes.Name.IMPLEMENTATION_VENDOR));
+        assertEquals(spec, m.getAttributes(ATT_ENTRY_NAME).get(
+                Attributes.Name.SPECIFICATION_TITLE));
+    }
 
     /**
      * @tests {@link java.util.jar.Manifest#read(java.io.InputStream)
      */
-    public void test_readLjava_io_InputStream() {
+    public void testRead() {
         // Regression for HARMONY-89
         InputStream is = new InputStreamImpl();
         try {
             new Manifest().read(is);
-            fail("Assert 0: Should have thrown IOException");
+            fail("IOException expected");
         } catch (IOException e) {
-            // expected
+            // desired
         }
     }
 
     // helper class
-    class InputStreamImpl extends InputStream {
+    private class InputStreamImpl extends InputStream {
         public InputStreamImpl() {
             super();
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/util/UtilTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/util/UtilTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/util/UtilTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/archive/src/test/java/org/apache/harmony/archive/util/UtilTest.java Wed Apr  9 04:01:14 2008
@@ -32,8 +32,9 @@
     }
 
     public void testToASCIILowerCase() {
-        assertEquals("abcdefghijklmnopqrstuvwxyz", Util //$NON-NLS-1$
-                .toASCIILowerCase("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); //$NON-NLS-1$
+        assertEquals(
+                "abcdefghijklmnopqrstuvwxyz", org.apache.harmony.luni.util.Util //$NON-NLS-1$
+                        .toASCIILowerCase("ABCDEFGHIJKLMNOPQRSTUVWXYZ")); //$NON-NLS-1$
 
         for (int i = 0; i < 255; i++) {
             if (i >= 'a' && i <= 'z') {
@@ -43,13 +44,15 @@
                 continue;
             }
             String cString = "" + (char) i; //$NON-NLS-1$
-            assertEquals(cString, Util.toASCIILowerCase(cString));
+            assertEquals(cString, org.apache.harmony.luni.util.Util
+                    .toASCIILowerCase(cString));
         }
     }
 
     public void testToASCIIUpperCase() {
-        assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", Util //$NON-NLS-1$
-                .toASCIIUpperCase("abcdefghijklmnopqrstuvwxyz")); //$NON-NLS-1$
+        assertEquals(
+                "ABCDEFGHIJKLMNOPQRSTUVWXYZ", org.apache.harmony.luni.util.Util //$NON-NLS-1$
+                        .toASCIIUpperCase("abcdefghijklmnopqrstuvwxyz")); //$NON-NLS-1$
 
         for (int i = 0; i < 255; i++) {
             if (i >= 'a' && i <= 'z') {
@@ -59,11 +62,12 @@
                 continue;
             }
             String cString = "" + (char) i; //$NON-NLS-1$
-            assertEquals(cString, Util.toASCIIUpperCase(cString));
+            assertEquals(cString, org.apache.harmony.luni.util.Util
+                    .toASCIIUpperCase(cString));
         }
     }
-    
-    public void testEqualsIgnoreCase(){
+
+    public void testEqualsIgnoreCase() {
         assertTrue(Util.equalsIgnoreCase(s1, s2));
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/auth/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/auth/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/auth/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/auth/build.xml Wed Apr  9 04:01:14 2008
@@ -141,7 +141,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/${hy.auth.packaging.jarname}.jar"
-             manifest="${hy.auth}/META-INF/MANIFEST.MF">
+             manifest="${hy.auth}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/build.xml Wed Apr  9 04:01:14 2008
@@ -124,7 +124,8 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/awt.jar"
-             manifest="${hy.awt}/META-INF/MANIFEST.MF">
+             manifest="${hy.awt}/META-INF/MANIFEST.MF"
+             compress="${hy.jar.compress}">
             <fileset refid="classes" />
             <manifest>
                 <attribute name="Implementation-Version" value="${svn.info}"/> 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Canvas.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Canvas.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Canvas.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Canvas.java Wed Apr  9 04:01:14 2008
@@ -119,7 +119,7 @@
     public void paint(Graphics g) {
         toolkit.lockAWT();
         try {
-            // just do nothing
+            g.clearRect(0, 0, w, h);
         } finally {
             toolkit.unlockAWT();
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Component.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Component.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Component.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Component.java Wed Apr  9 04:01:14 2008
@@ -79,6 +79,7 @@
 
 import org.apache.harmony.awt.ClipRegion;
 import org.apache.harmony.awt.FieldsAccessor;
+import org.apache.harmony.awt.gl.CommonGraphics2D;
 import org.apache.harmony.awt.gl.MultiRectArea;
 import org.apache.harmony.awt.internal.nls.Messages;
 import org.apache.harmony.awt.state.State;
@@ -947,8 +948,8 @@
         PrivilegedAction<String[]> action = new PrivilegedAction<String[]>() {
             public String[] run() {
                 String properties[] = new String[2];
-                properties[0] = System.getProperty("awt.image.redrawrate", "100"); //$NON-NLS-1$ //$NON-NLS-2$
-                properties[1] = System.getProperty("awt.image.incrementaldraw", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+                properties[0] = org.apache.harmony.awt.Utils.getSystemProperty("awt.image.redrawrate", "100"); //$NON-NLS-1$ //$NON-NLS-2$
+                properties[1] = org.apache.harmony.awt.Utils.getSystemProperty("awt.image.incrementaldraw", "true"); //$NON-NLS-1$ //$NON-NLS-2$
                 return properties;
             }
         };
@@ -3714,6 +3715,7 @@
         } else {
             update(g);
         }
+        ((CommonGraphics2D)g).flush();
         g.dispose();
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Cursor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Cursor.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Cursor.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Cursor.java Wed Apr  9 04:01:14 2008
@@ -195,7 +195,7 @@
         }
         String sep = File.separator;
         String cursorsDir = "lib" + sep + "images" + sep + "cursors"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        String cursorsAbsDir = System.getProperty("java.home") + sep + //$NON-NLS-1$
+        String cursorsAbsDir = org.apache.harmony.awt.Utils.getSystemProperty("java.home") + sep + //$NON-NLS-1$
                                 cursorsDir;
         String cursorPropsFileName = "cursors.properties"; //$NON-NLS-1$
         String cursorPropsFullFileName = (cursorsAbsDir + sep +

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Font.java Wed Apr  9 04:01:14 2008
@@ -593,7 +593,7 @@
     }
 
     public static Font getFont(String sp, Font f) {
-        String pr = System.getProperty(sp);
+        String pr = org.apache.harmony.awt.Utils.getSystemProperty(sp);
         if (pr == null) {
             return f;
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java Wed Apr  9 04:01:14 2008
@@ -22,6 +22,8 @@
 package java.awt;
 
 import java.awt.image.BufferedImage;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Locale;
 
 import org.apache.harmony.awt.ContextStorage;
@@ -29,6 +31,9 @@
 
 
 public abstract class GraphicsEnvironment {
+
+    static Boolean isHeadless;
+
     protected GraphicsEnvironment() {}
 
     public static GraphicsEnvironment getLocalGraphicsEnvironment() {
@@ -55,7 +60,11 @@
     }
 
     public static boolean isHeadless() {
-        return "true".equals(System.getProperty("java.awt.headless"));
+        if (isHeadless == null) {
+            isHeadless = "true".equals(org.apache.harmony.awt.Utils.getSystemProperty("java.awt.headless")); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        
+        return isHeadless.booleanValue();
     }
 
     public Rectangle getMaximumWindowBounds() throws HeadlessException {

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Toolkit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Toolkit.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Toolkit.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Toolkit.java Wed Apr  9 04:01:14 2008
@@ -1276,12 +1276,8 @@
     private static Theme createTheme() {
         String osName = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
         String packageBase = "org.apache.harmony.awt.theme", win = "windows", lin = "linux"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        PrivilegedAction<String> action = new PrivilegedAction<String>() {
-            public String run() {
-                return System.getProperty("awt.theme"); //$NON-NLS-1$
-            }
-        };
-        String className = AccessController.doPrivileged(action);
+        String className = org.apache.harmony.awt.Utils.getSystemProperty("awt.theme"); //$NON-NLS-1$
+
         if (className == null) {
             if (osName.startsWith(lin)) {
                 className = packageBase + "." + lin + ".LinuxTheme"; //$NON-NLS-1$ //$NON-NLS-2$

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Window.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Window.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Window.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/Window.java Wed Apr  9 04:01:14 2008
@@ -662,12 +662,9 @@
         if (sm.checkTopLevelWindow(this)) {
             return null;
         }
-        PrivilegedAction<String> action = new PrivilegedAction<String>() {
-            public String run() {
-                return System.getProperty("awt.appletWarning", "Warning: Java window"); //$NON-NLS-1$ //$NON-NLS-2$
-            }
-        };
-        return AccessController.doPrivileged(action);
+
+        return org.apache.harmony.awt.Utils.getSystemProperty(
+                        "awt.appletWarning", "Warning: Java window"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     public boolean isActive() {



Mime
View raw message