summaryrefslogtreecommitdiffstats
path: root/archive/src
diff options
context:
space:
mode:
Diffstat (limited to 'archive/src')
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java1
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java41
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java41
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java2
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java23
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java33
6 files changed, 67 insertions, 74 deletions
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
index 1a8c753..64e0e1a 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
@@ -180,7 +180,6 @@ public class JarInputStreamTest extends junit.framework.TestCase {
args = {}
)
@KnownFailure("IOException not thrown when using getNextJarEntry() after close().")
- // This is the original test_getNextJarEntry including the failing section.
public void test_getNextJarEntry_Ex() throws Exception {
final Set<String> desired = new HashSet<String>(Arrays
.asList(new String[] {
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java
index 355fd27..0d72108 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200PackerTest.java
@@ -25,6 +25,8 @@ import junit.framework.TestCase;
import tests.support.resource.Support_Resources;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -128,9 +130,7 @@ public class Pack200PackerTest extends TestCase {
assertTrue(packFile2.length()>packFile3.length());
}
-/*
- * java.beans.* not implemented yet on android platform
- * class MyPCL implements PropertyChangeListener {
+ class MyPCL implements PropertyChangeListener {
boolean flag = false;
public boolean isCalled() {
@@ -141,15 +141,14 @@ public class Pack200PackerTest extends TestCase {
flag = true;
}
}
-@TestInfo(
- level = TestLevel.COMPLETE,
-
- targets = {
- @TestTarget(
- methodName = "addPropertyChangeListener",
- methodArgs = {java.beans.PropertyChangeListener.class}
- )
- })
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "addPropertyChangeListener",
+ args = {java.beans.PropertyChangeListener.class}
+ )
+ @KnownFailure("No Implementation in Android!")
public void testAddPropertyChangeListener() {
MyPCL pcl = new MyPCL();
packer.addPropertyChangeListener(pcl);
@@ -158,15 +157,13 @@ public class Pack200PackerTest extends TestCase {
assertTrue(pcl.isCalled());
}
-@TestInfo(
- level = TestLevel.COMPLETE,
-
- targets = {
- @TestTarget(
- methodName = "removePropertyChangeListener",
- methodArgs = {java.beans.PropertyChangeListener.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "removePropertyChangeListener",
+ args = {java.beans.PropertyChangeListener.class}
+ )
+ @KnownFailure("No Implementation in Android!")
public void testRemovePropertyChangeListener() {
MyPCL pcl = new MyPCL();
packer.addPropertyChangeListener(pcl);
@@ -175,7 +172,7 @@ public class Pack200PackerTest extends TestCase {
properties.put(Packer.EFFORT, "7");
assertFalse(pcl.isCalled());
}
-*/
+
@Override
protected void setUp() {
packer = Pack200.newPacker();
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java
index 4d5ede3..c1f9813 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/Pack200UnpackerTest.java
@@ -25,6 +25,8 @@ import junit.framework.TestCase;
import tests.support.resource.Support_Resources;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -176,9 +178,8 @@ public class Pack200UnpackerTest extends TestCase {
assertEquals(jarEntries, new JarFile(jarFile2).size());
assertEquals(jarEntries, new JarFile(jarFile3).size());
}
-/*
- * java.beans.* not implemented yet on android platform
- * class MyPCL implements PropertyChangeListener {
+
+ class MyPCL implements PropertyChangeListener {
boolean flag = false;
public boolean isCalled() {
@@ -190,15 +191,13 @@ public class Pack200UnpackerTest extends TestCase {
}
}
-@TestInfo(
- level = TestLevel.COMPLETE,
-
- targets = {
- @TestTarget(
- methodName = "addPropertyChangeListener",
- methodArgs = {java.beans.PropertyChangeListener.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "addPropertyChangeListener",
+ args = {java.beans.PropertyChangeListener.class}
+ )
+ @KnownFailure("No Implementation in Android!")
public void testAddPropertyChangeListener() {
MyPCL pcl = new MyPCL();
unpacker.addPropertyChangeListener(pcl);
@@ -207,15 +206,13 @@ public class Pack200UnpackerTest extends TestCase {
assertTrue(pcl.isCalled());
}
-@TestInfo(
- level = TestLevel.COMPLETE,
-
- targets = {
- @TestTarget(
- methodName = "removePropertyChangeListener",
- methodArgs = {java.beans.PropertyChangeListener.class}
- )
- })
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ notes = "",
+ method = "removePropertyChangeListener",
+ args = {java.beans.PropertyChangeListener.class}
+ )
+ @KnownFailure("No Implementation in Android!")
public void testRemovePropertyChangeListener() {
MyPCL pcl = new MyPCL();
unpacker.addPropertyChangeListener(pcl);
@@ -224,7 +221,7 @@ public class Pack200UnpackerTest extends TestCase {
properties.put(Unpacker.PROGRESS, "7");
assertFalse(pcl.isCalled());
}
-*/
+
@Override
protected void setUp() {
unpacker = Pack200.newUnpacker();
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
index 2e91510..2de996e 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java
@@ -17,7 +17,6 @@
package org.apache.harmony.archive.tests.java.util.zip;
-import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
@@ -36,7 +35,6 @@ import java.io.InputStream;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
-import java.util.zip.ZipException;
@TestTargetClass(InflaterInputStream.class)
public class InflaterInputStreamTest extends TestCase {
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
index 3fe23a7..468a803 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java
@@ -17,8 +17,8 @@
package org.apache.harmony.archive.tests.java.util.zip;
-import dalvik.annotation.AndroidOnly;
import dalvik.annotation.KnownFailure;
+import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
@@ -28,6 +28,7 @@ import tests.support.resource.Support_Resources;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -40,10 +41,9 @@ import java.util.zip.ZipFile;
@TestTargetClass(ZipFile.class)
public class ZipFileTest extends junit.framework.TestCase {
- // BEGIN android-added
public byte[] getAllBytesFromStream(InputStream is) throws IOException {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
- byte[] buf = new byte[666];
+ byte[] buf = new byte[512];
int iRead;
int off;
while (is.available() > 0) {
@@ -53,8 +53,6 @@ public class ZipFileTest extends junit.framework.TestCase {
return bs.toByteArray();
}
- // END android-added
-
// the file hyts_zipFile.zip in setup must be included as a resource
private String tempFileName;
@@ -67,7 +65,10 @@ public class ZipFileTest extends junit.framework.TestCase {
public void checkPermission(Permission perm) {
- if (perm.getActions().equals(forbidenPermissionAction)) {
+ // only check if it's a FilePermission because Locale checks
+ // for a PropertyPermission with action"read" to get system props.
+ if (perm instanceof FilePermission
+ && perm.getActions().equals(forbidenPermissionAction)) {
throw new SecurityException();
}
}
@@ -327,7 +328,7 @@ public class ZipFileTest extends junit.framework.TestCase {
method = "getEntry",
args = {java.lang.String.class}
)
- @AndroidOnly("God knows why!")
+ @BrokenTest("Needs investigation. AndroidOnly?")
public void test_getEntryLjava_lang_String_AndroidOnly() throws IOException {
java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
assertNotNull("Could not obtain ZipEntry", zentry);
@@ -349,7 +350,8 @@ public class ZipFileTest extends junit.framework.TestCase {
method = "getEntry",
args = {java.lang.String.class}
)
- @KnownFailure("Android does not throw IllegalStateException when using getEntry() after close().")
+ @KnownFailure("Android does not throw IllegalStateException when using "
+ + "getEntry() after close().")
public void test_getEntryLjava_lang_String_Ex() throws IOException {
java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
assertNotNull("Could not obtain ZipEntry", zentry);
@@ -434,7 +436,8 @@ public class ZipFileTest extends junit.framework.TestCase {
method = "size",
args = {}
)
- @KnownFailure("IllegalStateException not thrown when using ZipFile.size() after close().")
+ @KnownFailure("IllegalStateException not thrown when using ZipFile.size() "
+ + "after close().")
public void test_size() throws IOException {
assertEquals(6, zfile.size());
zfile.close();
@@ -453,7 +456,6 @@ public class ZipFileTest extends junit.framework.TestCase {
@Override
protected void setUp() {
try {
- // BEGIN android-changed
// Create a local copy of the file since some tests want to alter
// information.
tempFileName = System.getProperty("java.io.tmpdir");
@@ -471,7 +473,6 @@ public class ZipFileTest extends junit.framework.TestCase {
f.delete();
InputStream is = Support_Resources.getStream("hyts_ZipFile.zip");
FileOutputStream fos = new FileOutputStream(f);
- // END android-changed
byte[] rbuf = getAllBytesFromStream(is);
fos.write(rbuf, 0, rbuf.length);
is.close();
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
index bdab74a..ac332fa 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java
@@ -174,7 +174,8 @@ public class ZipInputStreamTest extends TestCase {
method = "close",
args = {}
)
- @KnownFailure("The behaviour is different from RI, but not neccessarily wrong.")
+ @KnownFailure("after an exception has been thrown wile reading a "
+ + "call to close also throws an exception.")
public void test_closeAfterException() throws Exception {
File resources = Support_Resources.createTempFolder();
Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
@@ -192,7 +193,7 @@ public class ZipInputStreamTest extends TestCase {
// expected
}
- zis1.close(); // Android throws exception here, but RI only when getNextEntry/read/skip are called.
+ zis1.close();
try {
zis1.getNextEntry();
fail("IOException expected");
@@ -346,31 +347,31 @@ public class ZipInputStreamTest extends TestCase {
method = "available",
args = {}
)
- @KnownFailure("Needs investigation!!!")
public void test_available() throws Exception {
File resources = Support_Resources.createTempFolder();
- Support_Resources.copyFile(resources, null, "Broken_manifest.jar");
- File fl = new File(resources, "Broken_manifest.jar");
+ Support_Resources.copyFile(resources, null, "hyts_ZipFile.zip");
+ File fl = new File(resources, "hyts_ZipFile.zip");
FileInputStream fis = new FileInputStream(fl);
ZipInputStream zis1 = new ZipInputStream(fis);
+ ZipEntry entry = zis1.getNextEntry();
+ assertNotNull("No entry in the archive.", entry);
+ long entrySize = entry.getSize();
+ assertTrue("Entry size was < 1", entrySize > 0);
int i = 0;
-System.out.println(fl.length());
- for (i = 0; i < fl.length(); i++) {
-//System.out.println(i);
+ for (i = 0; i < entrySize; i++) {
zis1.skip(1);
-//System.out.println("Skipped 1");
-int avail = zis1.available();
-//System.out.println(avail);
- if (zis1.available() == 0) break; // RI breaks at i = 0 already; Android loops till the end!
-//System.out.println("Looping...");
+ if (zis1.available() == 0) break;
}
- if (i == fl.length()) {
- fail("ZipInputStream.available or ZipInputStream.skip does not working properly");
+ if (i != entrySize) {
+ fail("ZipInputStream.available or ZipInputStream.skip does not " +
+ "working properly. Only skipped " + i +
+ " bytes instead of " + entrySize);
}
- assertTrue(zis1.available() == 0);
zis1.skip(1);
+ assertTrue(zis1.available() == 0);
+ zis1.closeEntry();
assertFalse(zis.available() == 0);
zis1.close();
try {