summaryrefslogtreecommitdiffstats
path: root/archive/src
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-18 17:39:42 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-18 17:39:42 -0700
commit7387da1059039afc7d8fd3e48e4d0712fff5dfaf (patch)
tree1637f1cfa85cbade78241ca9adc14dd4ddb3dd8d /archive/src
parentfa890109ecc4522f0e07481431c04d4cf6ba16d1 (diff)
downloadlibcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.zip
libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.tar.gz
libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.tar.bz2
auto import from //branches/cupcake_rel/...@140373
Diffstat (limited to 'archive/src')
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java18
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java18
-rw-r--r--archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java7
3 files changed, 17 insertions, 26 deletions
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
index 3b5cdb4..4450bdf 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java
@@ -18,7 +18,6 @@
package org.apache.harmony.archive.tests.java.util.zip;
import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargets;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetNew;
@@ -36,17 +35,6 @@ import tests.support.resource.Support_Resources;
@TestTargetClass(CheckedInputStream.class)
public class CheckedInputStreamTest extends TestCase {
- @Override
- protected void tearDown() {
- try {
- File deletedFile = new File("empty.txt");
- deletedFile.delete();
- } catch (SecurityException e) {
- fail("Cannot delete file for security reasons");
- }
-
- }
-
/**
* @tests java.util.zip.CheckedInputStream#CheckedInputStream(java.io.InputStream,
* java.util.zip.Checksum)
@@ -80,9 +68,11 @@ public class CheckedInputStreamTest extends TestCase {
public void test_getChecksum() throws Exception {
byte outBuf[] = new byte[100];
// testing getChecksum for an empty file
- FileOutputStream outEmp = new FileOutputStream("empty.txt");
+ File empty = File.createTempFile("empty", ".txt");
+ empty.deleteOnExit();
+ FileOutputStream outEmp = new FileOutputStream(empty);
outEmp.close();
- InputStream inEmp = new FileInputStream("empty.txt");
+ InputStream inEmp = new FileInputStream(empty);
CheckedInputStream checkEmpty = new CheckedInputStream(inEmp,
new CRC32());
while (checkEmpty.read() >= 0) {
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
index 9a804c1..ed7238c 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java
@@ -102,7 +102,7 @@ public class DeflaterOutputStreamTest extends TestCase {
public void test_ConstructorLjava_io_OutputStreamLjava_util_zip_Deflater()
throws Exception {
byte byteArray[] = {1, 3, 4, 7, 8};
- File f1 = new File("hyts_Constru_OD.tst");
+ File f1 = File.createTempFile("hyts_Constru_OD", ".tst");
FileOutputStream fos = new FileOutputStream(f1);
Deflater defl = null;
MyDeflaterOutputStream dos;
@@ -134,7 +134,7 @@ public class DeflaterOutputStreamTest extends TestCase {
args = {java.io.OutputStream.class}
)
public void test_ConstructorLjava_io_OutputStream() throws Exception {
- File f1 = new File("hyts_Constru_O.tst");
+ File f1 = File.createTempFile("hyts_Constru_O", ".tst");
FileOutputStream fos = new FileOutputStream(f1);
MyDeflaterOutputStream dos = new MyDeflaterOutputStream(fos);
@@ -163,7 +163,7 @@ public class DeflaterOutputStreamTest extends TestCase {
int negBuf = -5;
int zeroBuf = 0;
byte byteArray[] = {1, 3, 4, 7, 8, 3, 6};
- File f1 = new File("hyts_Constru_ODI.tst");
+ File f1 = File.createTempFile("hyts_Constru_ODI", ".tst");
FileOutputStream fos = new FileOutputStream(f1);
Deflater defl = null;
MyDeflaterOutputStream dos;
@@ -210,7 +210,7 @@ public class DeflaterOutputStreamTest extends TestCase {
args = {}
)
public void test_close() throws Exception {
- File f1 = new File("close.tst");
+ File f1 = File.createTempFile("close", ".tst");
FileOutputStream fos = new FileOutputStream(f1);
DeflaterOutputStream dos = new DeflaterOutputStream(fos);
byte byteArray[] = {1, 3, 4, 6};
@@ -277,7 +277,7 @@ public class DeflaterOutputStreamTest extends TestCase {
// Need test to see if method finish() actually finishes
// Only testing possible errors, not if it actually works
- File f1 = new File("finish.tst");
+ File f1 = File.createTempFile("finish", ".tst");
FileOutputStream fos1 = new FileOutputStream(f1);
DeflaterOutputStream dos = new DeflaterOutputStream(fos1);
byte byteArray[] = {1, 3, 4, 6};
@@ -331,7 +331,7 @@ public class DeflaterOutputStreamTest extends TestCase {
args = {int.class}
)
public void test_writeI() throws Exception {
- File f1 = new File("writeI1.tst");
+ File f1 = File.createTempFile("writeI1", ".tst");
FileOutputStream fos = new FileOutputStream(f1);
DeflaterOutputStream dos = new DeflaterOutputStream(fos);
for (int i = 0; i < 3; i++) {
@@ -376,7 +376,7 @@ public class DeflaterOutputStreamTest extends TestCase {
byte byteArray[] = {1, 3, 4, 7, 8, 3, 6};
// Test to see if the correct bytes are saved.
- File f1 = new File("writeBII.tst");
+ File f1 = File.createTempFile("writeBII", ".tst");
FileOutputStream fos1 = new FileOutputStream(f1);
DeflaterOutputStream dos1 = new DeflaterOutputStream(fos1);
dos1.write(byteArray, 2, 3);
@@ -392,7 +392,7 @@ public class DeflaterOutputStreamTest extends TestCase {
f1.delete();
// Test for trying to write more bytes than available from the array
- File f2 = new File("writeBII2.tst");
+ File f2 = File.createTempFile("writeBII", ".tst");
FileOutputStream fos2 = new FileOutputStream(f2);
DeflaterOutputStream dos2 = new DeflaterOutputStream(fos2);
try {
@@ -448,7 +448,7 @@ public class DeflaterOutputStreamTest extends TestCase {
args = {}
)
public void test_deflate() throws Exception {
- File f1 = new File("writeI1.tst");
+ File f1 = File.createTempFile("writeI1", ".tst");
FileOutputStream fos = new FileOutputStream(f1);
MyDeflaterOutputStream dos = new MyDeflaterOutputStream(fos);
assertFalse(dos.getDaflateFlag());
diff --git a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java
index f8862d4..ee7aceb 100644
--- a/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java
+++ b/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java
@@ -25,6 +25,7 @@ import dalvik.annotation.TestTargetNew;
import tests.support.resource.Support_Resources;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.TimeZone;
@@ -36,7 +37,7 @@ public class ZipEntryTest 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) {
@@ -57,7 +58,7 @@ public class ZipEntryTest extends junit.framework.TestCase {
"com.ibm.oti.configuration", "JDK")
+ System.getProperty("java.vm.version");
- static final String tempFileName = platformId + "zfzezi.zip";
+ static final String tempFileName = platformId + "zipentrytest.zip";
long orgSize;
@@ -598,7 +599,7 @@ public class ZipEntryTest extends junit.framework.TestCase {
// BEGIN android-changed
// Create a local copy of the file since some tests want to alter
// information.
- f = new java.io.File(tempFileName);
+ f = File.createTempFile(tempFileName, ".zip");
// Create absolute filename as ZipFile does not resolve using
// user.dir
f = new java.io.File(f.getAbsolutePath());