diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:42 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:42 -0700 |
commit | 7387da1059039afc7d8fd3e48e4d0712fff5dfaf (patch) | |
tree | 1637f1cfa85cbade78241ca9adc14dd4ddb3dd8d | |
parent | fa890109ecc4522f0e07481431c04d4cf6ba16d1 (diff) | |
download | libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.zip libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.tar.gz libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.tar.bz2 |
auto import from //branches/cupcake_rel/...@140373
26 files changed, 315 insertions, 322 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()); diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java index 862cced..906057b 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java @@ -33,15 +33,15 @@ public class AllTests { TestSuite suite = new TestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto.func;"); // $JUnit-BEGIN$ - suite.addTestSuite(CipherDesTest.class); suite.addTestSuite(CipherAesTest.class); suite.addTestSuite(CipherAesWrapTest.class); suite.addTestSuite(CipherDESedeTest.class); suite.addTestSuite(CipherDESedeWrapTest.class); + suite.addTestSuite(CipherDesTest.class); suite.addTestSuite(CipherPBETest.class); suite.addTestSuite(CipherRSATest.class); - suite.addTestSuite(KeyGeneratorFunctionalTest.class); suite.addTestSuite(KeyAgreementFunctionalTest.class); + suite.addTestSuite(KeyGeneratorFunctionalTest.class); suite.addTestSuite(MacFunctionalTest.class); suite.addTestSuite(SecretKeyFactoryFunctionalTest.class); diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java index ce62332..d00c62b 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java @@ -25,49 +25,53 @@ import targets.Cipher; @TestTargetClass(Cipher.AES.class) public class CipherAesTest extends TestCase { -// 76 cases checked +// 216 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_AesNoISO() { CipherSymmetricKeyThread aesNoISO = new CipherSymmetricKeyThread("AES", - new int[]{128},//Keysize must be equal to 128, 192, or 256. - new String[] {"ECB", "CBC", "CTR", "CTS", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", - "CFB72", "CFB80", "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", - "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", "OFB40", - "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", "OFB88", "OFB96", - "OFB104", "OFB112", "OFB120", "OFB128"}, - new String[]{"NoPadding", "PKCS5Padding"}); + new int[] {128, 192, 256}, // Keysize must be 128, 192, 256. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "CFB72", "CFB80", + "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", + "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", + "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", + "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", + "OFB128"}, new String[] {"NoPadding", "PKCS5Padding"}); aesNoISO.launcher(); - assertEquals(aesNoISO.getFailureMessages(), 0, aesNoISO.getTotalFailuresNumber()); + assertEquals(aesNoISO.getFailureMessages(), 0, aesNoISO + .getTotalFailuresNumber()); } -// 36 cases checked +// 108 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_AesISO() { CipherSymmetricKeyThread aesISO = new CipherSymmetricKeyThread("AES", - new int[]{128},//Keysize must be equal to 128, 192, or 256. - new String[] {"ECB", "CBC", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", - "CFB72", "CFB80", "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", - "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", "OFB40", - "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", "OFB88", "OFB96", - "OFB104", "OFB112", "OFB120", "OFB128"}, - new String[] {"ISO10126PADDING"}); + new int[] {128, 192, 256}, // Keysize must be 128, 192, 256. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "CFB72", "CFB80", + "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", + "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", + "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", + "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", + "OFB128"}, new String[] {"ISO10126PADDING"}); aesISO.launcher(); - assertEquals(aesISO.getFailureMessages(), 0, aesISO.getTotalFailuresNumber()); + assertEquals(aesISO.getFailureMessages(), 0, aesISO + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java index 2c75abd..d196edc 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java @@ -25,32 +25,21 @@ import targets.Cipher; @TestTargetClass(Cipher.AESWrap.class) public class CipherAesWrapTest extends TestCase { -// one case checked. Mode "ECB" not supported. +// 3 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_AesWrap() { - CipherWrapThread aesWrap = new CipherWrapThread("AESWrap", - new int[]{128}, - new String[] {"ECB"}, - new String[] {"NoPadding"}); + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) + public void test_AesWrap() { + CipherWrapThread aesWrap = new CipherWrapThread("AESWrap", new int[] { + 128, 192, 256}, // Keysize must be 128, 192, 256. + new String[] {"ECB"}, new String[] {"NoPadding"}); aesWrap.launcher(); - - assertEquals(aesWrap.getFailureMessages(), 0, aesWrap.getTotalFailuresNumber()); - } - - public void test_AesWrap1() { - CipherWrapThread aesWrap = new CipherWrapThread("AES", - new int[]{128}, - new String[] {"ECB"}, - new String[] {"NoPadding"}); - aesWrap.launcher(); - - assertEquals(aesWrap.getFailureMessages(), 0, aesWrap.getTotalFailuresNumber()); + assertEquals(aesWrap.getFailureMessages(), 0, aesWrap + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java index c6053b6..7352e83 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java @@ -25,45 +25,47 @@ import targets.Cipher; @TestTargetClass(Cipher.DESede.class) public class CipherDESedeTest extends TestCase { -// 88 cases checked +// 80 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DESedeNoISO() { - CipherSymmetricKeyThread DESedeNoISO = new CipherSymmetricKeyThread("DESede", - new int[]{112, 168},//Keysize must be equal to 112 or 168. - new String[] {"ECB", "CBC", "CTR", "CTS", "CFB", "CFB8", "CFB16", - "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", "OFB", - "OFB8", "OFB16", "OFB24", "OFB32","OFB40", "OFB48", "OFB56", - "OFB64"}, - new String[]{"NoPadding", "PKCS5Padding"}); + CipherSymmetricKeyThread DESedeNoISO = new CipherSymmetricKeyThread( + "DESede", new int[] {112, 168},// Keysize must be 112 or 168. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"NoPadding", "PKCS5Padding"}); DESedeNoISO.launcher(); - - assertEquals(DESedeNoISO.getFailureMessages(), 0, DESedeNoISO.getTotalFailuresNumber()); + + assertEquals(DESedeNoISO.getFailureMessages(), 0, DESedeNoISO + .getTotalFailuresNumber()); } -// 40 cases checked +// 40 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DESedeISO() { - CipherSymmetricKeyThread DESedeISO = new CipherSymmetricKeyThread("DESede", - new int[]{112, 168},//Keysize must be equal to 112 or 168. - new String[] {"ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", - "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", "OFB", - "OFB8", "OFB16", "OFB24", "OFB32","OFB40", "OFB48", - "OFB56", "OFB64"}, - new String[]{"ISO10126PADDING"}); + CipherSymmetricKeyThread DESedeISO = new CipherSymmetricKeyThread( + "DESede", new int[] {112, 168},// Keysize must be 112 or 168. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"ISO10126PADDING"}); DESedeISO.launcher(); - - assertEquals(DESedeISO.getFailureMessages(), 0, DESedeISO.getTotalFailuresNumber()); + + assertEquals(DESedeISO.getFailureMessages(), 0, DESedeISO + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java index e2c9c9e..2169a93 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java @@ -25,21 +25,21 @@ import targets.Cipher; @TestTargetClass(Cipher.DESedeWrap.class) public class CipherDESedeWrapTest extends TestCase { -// 2 cases checked. Mode "CBC" not supported. +// 2 cases checked. @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DESedeWrap() { CipherWrapThread DESedeWrap = new CipherWrapThread("DESedeWrap", - new int[]{112, 168}, - new String[] {"CBC"}, - new String[]{"NoPadding"}); + new int[] {112, 168}, // Keysize must be 112 or 168. + new String[] {"CBC"}, new String[] {"NoPadding"}); DESedeWrap.launcher(); - - assertEquals(DESedeWrap.getFailureMessages(), 0, DESedeWrap.getTotalFailuresNumber()); + + assertEquals(DESedeWrap.getFailureMessages(), 0, DESedeWrap + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java index 7b11ae9..6f8fbc3 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java @@ -25,45 +25,47 @@ import targets.Cipher; @TestTargetClass(Cipher.DES.class) public class CipherDesTest extends TestCase { -// 44 cases checked +// 40 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DesNoISO() { CipherSymmetricKeyThread desNoISO = new CipherSymmetricKeyThread("DES", - new int[]{56},//Keysize must be equal to 56. - new String[] {"ECB", "CBC", "CTR", "CTS", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", - "CFB64", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", - "OFB40", "OFB48", "OFB56", "OFB64"}, - new String[]{"NoPadding", "PKCS5Padding"}); + new int[] {56},// Keysize must be 56. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"NoPadding", "PKCS5Padding"}); desNoISO.launcher(); - - assertEquals(desNoISO.getFailureMessages(), 0, desNoISO.getTotalFailuresNumber()); + + assertEquals(desNoISO.getFailureMessages(), 0, desNoISO + .getTotalFailuresNumber()); } // 20 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DesISO() { CipherSymmetricKeyThread desISO = new CipherSymmetricKeyThread("DES", - new int[]{56},//Keysize must be equal to 56. - new String[] {"ECB", "CBC", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", - "CFB64", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", - "OFB40", "OFB48", "OFB56", "OFB64"}, - new String[]{"ISO10126PADDING"}); - + new int[] {56},// Keysize must be 56. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"ISO10126PADDING"}); + desISO.launcher(); - - assertEquals(desISO.getFailureMessages(), 0, desISO.getTotalFailuresNumber()); + + assertEquals(desISO.getFailureMessages(), 0, desISO + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java index a3fb3c2..3ea1f13 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java @@ -15,6 +15,7 @@ */ package org.apache.harmony.crypto.tests.javax.crypto.func; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -25,75 +26,88 @@ import targets.Cipher; @TestTargetClass(Cipher.PBE.class) public class CipherPBETest extends TestCase { -// 2 cases checked + @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.PARTIAL_COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_PBEWithMD5AndDES() throws Exception { - CipherPBEThread PBEWithMD5AndDES = new CipherPBEThread("PBEWithMD5AndDES", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"PKCS5Padding"}); + CipherPBEThread PBEWithMD5AndDES = new CipherPBEThread( + "PBEWithMD5AndDES", new int[] {56}, new String[] {"CBC"}, + new String[] {"PKCS5Padding"}); PBEWithMD5AndDES.launcher(); - assertEquals(PBEWithMD5AndDES.getFailureMessages(), 0, PBEWithMD5AndDES.getTotalFailuresNumber()); + assertEquals(PBEWithMD5AndDES.getFailureMessages(), 0, PBEWithMD5AndDES + .getTotalFailuresNumber()); } -// 2 cases checked. Not supported on Android. @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_PBEWithSHA1AndDESede() throws Exception { - CipherPBEThread PBEWithSHA1AndDESede = new CipherPBEThread("PBEWithSHA1AndDESede", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"PKCS5Padding"}); + level = TestLevel.PARTIAL_COMPLETE, + notes = "", + method = "method", + args = {} + ) + @AndroidOnly("Not supported by RI (maybe with a different name)") + public void test_PBEWithSHAand3KeyTripleDES() throws Exception { + CipherPBEThread PBEWITHSHAAND3KEYTRIPLEDESCBC = new CipherPBEThread( + "PBEWITHSHAAND3-KEYTRIPLEDES-CBC", new int[] {112, 168}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); - PBEWithSHA1AndDESede.launcher(); + PBEWITHSHAAND3KEYTRIPLEDESCBC.launcher(); - assertEquals(PBEWithSHA1AndDESede.getFailureMessages(), 0, PBEWithSHA1AndDESede.getTotalFailuresNumber()); + assertEquals(PBEWITHSHAAND3KEYTRIPLEDESCBC.getFailureMessages(), 0, + PBEWITHSHAAND3KEYTRIPLEDESCBC.getTotalFailuresNumber()); } -// 2 cases checked. Not supported on Android. - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_PBEWithSHA1AndRC2_40() throws Exception { - CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread("PBEWithSHA1AndRC2_40", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"PKCS5Padding"}); + // Supported, but not part of mandatory components for Android + public void disabled_test_PBEWithSHA1And40BitRC2() throws Exception { + CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread( + "PBEWITHSHAAND40BITRC2-CBC", new int[] {40}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); PBEWithSHA1AndRC2_40.launcher(); - assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); + assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, + PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); } -// Key factory does not supported. - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_PBEWITHSHAAND3() throws Exception { - CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread("PBEWITHSHAAND3", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"NoPadding", "PKCS5Padding", "ISO10126PADDING"}); + + // Not supported by Android + public void disabled_test_PBEWithMD5AndTripleDES() throws Exception { + CipherPBEThread PBEWithMD5AndTripleDES = new CipherPBEThread( + "PBEWithMD5AndTripleDES", new int[] {112, 168}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); + + PBEWithMD5AndTripleDES.launcher(); + + assertEquals(PBEWithMD5AndTripleDES.getFailureMessages(), 0, + PBEWithMD5AndTripleDES.getTotalFailuresNumber()); + } + + // Not supported by Android + public void disabled_test_PBEWithSHA1AndDESede() throws Exception { + CipherPBEThread PBEWithSHA1AndDESede = new CipherPBEThread( + "PBEWithSHA1AndDESede", new int[] {112, 168}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); + + PBEWithSHA1AndDESede.launcher(); + + assertEquals(PBEWithSHA1AndDESede.getFailureMessages(), 0, + PBEWithSHA1AndDESede.getTotalFailuresNumber()); + } + + // Not supported by Android + public void disabled_test_PBEWithSHA1AndRC2_40() throws Exception { + CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread( + "PBEWithSHA1AndRC2_40", new int[] {40}, new String[] {"CBC"}, + new String[] {"PKCS5Padding"}); PBEWithSHA1AndRC2_40.launcher(); - assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); + assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, + PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java index 90cb956..5acc5b5 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java @@ -15,6 +15,7 @@ */ package org.apache.harmony.crypto.tests.javax.crypto.func; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -25,74 +26,60 @@ import targets.Cipher; @TestTargetClass(Cipher.RSA.class) public class CipherRSATest extends TestCase { -// 3 cases checked +// 3 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_RSAShortKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{512}, - new String[] {"ECB"}, - new String[]{"PKCS1Padding", - "OAEPWITHMD5ANDMGF1Padding", "OAEPWITHSHA1ANDMGF1Padding"}); + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {512}, + new String[] {"ECB"}, new String[] { + "PKCS1PADDING", "OAEPWITHMD5ANDMGF1PADDING", + "OAEPWITHSHA1ANDMGF1PADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_RSALongKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{1024}, + // Not supported by Android + public void disabled_test_RSALongKey() { + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {1024}, new String[] {"ECB"}, - new String[]{"OAEPWITHSHA-384ANDMGF1Padding"}); + new String[] {"OAEPWITHSHA-384ANDMGF1PADDING", + "OAEPWITHSHA-256ANDMGF1PADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_RSAXXXLKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{2048}, + // Not supported by Android + public void disabled_test_RSAXXXLKey() { + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {2048}, new String[] {"ECB"}, - new String[]{"OAEPWITHSHA-512ANDMGF1Padding"}); + new String[] {"OAEPWITHSHA-512ANDMGF1PADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } -// 2 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) + @AndroidOnly("Fails on RI but succeeds on Android.") public void test_RSANoPadding() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{512}, - new String[] {"ECB"}, - new String[]{"NoPadding", "ISO9796-1PADDING"}); + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {1024}, + new String[] {"ECB"}, new String[] {"NOPADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java index 2b34c1c..b0eabe2 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java @@ -33,8 +33,8 @@ public class CipherWrapThread extends CipherThread { kg.init(getKeyLength(), new SecureRandom()); Key key = kg.generateKey(); - Cipher cip = Cipher.getInstance(getAlgName() + "/" + getMode() + "/" + - getPadding()); + // ignore mode and padding + Cipher cip = Cipher.getInstance(getAlgName()); cip.init(Cipher.WRAP_MODE, key); byte[] output = cip.wrap(key); diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java index d0e5f6a..e706c77 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java @@ -16,21 +16,23 @@ package org.apache.harmony.crypto.tests.javax.crypto.func; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; +import dalvik.annotation.TestTargets; import junit.framework.TestCase; import targets.KeyAgreement; -@TestTargetClass(KeyAgreement.DH.class) public class KeyAgreementFunctionalTest extends TestCase { - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = KeyAgreement.DH.class, method = "method", args = {} ) + }) public void test_KeyAgreement() throws Exception { String[] algArray = {"DES", "DESede"}; diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java index dde6fbd..50b6ef6 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java @@ -16,7 +16,6 @@ package org.apache.harmony.crypto.tests.javax.crypto.func; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -24,66 +23,67 @@ import junit.framework.TestCase; import targets.KeyGenerator; -@TestTargetClass(KeyGenerator.AES.class) public class KeyGeneratorFunctionalTest extends TestCase { -@TestTargets({ - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = KeyGenerator.AES.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.DES.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.DESede.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACMD5.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA1.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA256.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA384.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA512.class, method = "method", args = {} - )}) + ) + }) public void test_() throws Exception { - String[] algArray = {/*"DH",*/ "AES", "DES", "DESEDE", "DESede", + String[] algArray = {"AES", "DES", "DESEDE", "DESede", "HMACMD5", "HmacMD5", "HMACSHA1", "HmacSHA1", "HMACSHA256", "HmacSHA256", "HMACSHA384", "HmacSHA384", "HMACSHA512", "HmacSHA512"}; diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java index bfe486a..6452cb4 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java @@ -16,7 +16,6 @@ package org.apache.harmony.crypto.tests.javax.crypto.func; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -24,44 +23,44 @@ import junit.framework.TestCase; import targets.Mac; -@TestTargetClass(Mac.HMACMD5.class) public class MacFunctionalTest extends TestCase { -@TestTargets({ - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = Mac.HMACMD5.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA1.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA256.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA384.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA512.class, method = "method", args = {} ) -}) + }) public void test_Mac() throws Exception { String[] algArray = {"HMACSHA1", "HMACSHA256", "HMACSHA384", "HMACSHA512", "HMACMD5"}; diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java index 286bb5b..35fb490 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java @@ -15,8 +15,8 @@ */ package org.apache.harmony.crypto.tests.javax.crypto.func; +import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -24,33 +24,32 @@ import junit.framework.TestCase; import targets.SecretKeyFactory; -@TestTargetClass(SecretKeyFactory.DES.class) public class SecretKeyFactoryFunctionalTest extends TestCase { -@TestTargets({ - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = SecretKeyFactory.DES.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = SecretKeyFactory.DESede.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = SecretKeyFactory.PBEWITHMD5ANDDES.class, method = "method", args = {} ) -}) + }) public void test_() throws Exception { - String[] algArray = {"DES", "DESede", "PBEWITHMD5ANDDES", - "PBEWithSHA1AndDESede", "PBEWithSHA1AndRC2_40"}; + String[] algArray = {"DES", "DESede", "PBEWITHMD5ANDDES"}; SecretKeyFactoryThread skft = new SecretKeyFactoryThread(algArray); skft.launcher(); diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java index 319418f..b95c5b7 100644 --- a/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java +++ b/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java @@ -74,7 +74,6 @@ import junit.framework.TestCase; * The password to the certstore should be "password" (without quotes). */ @TestTargetClass(HttpsURLConnection.class) -@AndroidOnly("we only have a .bks key store in the test resources") public class HttpsURLConnectionTest extends TestCase { // the password to the store @@ -127,6 +126,7 @@ public class HttpsURLConnectionTest extends TestCase { method = "getDefaultSSLSocketFactory", args = {} ) + @AndroidOnly("we only have a .bks key store in the test resources") public void testGetDefaultSSLSocketFactory() throws Exception { // set up the properties defining the default values needed by SSL stuff setUpStoreProperties(); @@ -160,6 +160,7 @@ public class HttpsURLConnectionTest extends TestCase { args = {javax.net.ssl.HostnameVerifier.class} ) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testHttpsConnection() throws Throwable { // set up the properties defining the default values needed by SSL stuff setUpStoreProperties(); @@ -218,6 +219,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testHttpsConnection_Not_Found_Response() throws Throwable { // set up the properties defining the default values needed by SSL stuff setUpStoreProperties(); @@ -265,6 +267,7 @@ public class HttpsURLConnectionTest extends TestCase { method = "setDefaultSSLSocketFactory", args = {javax.net.ssl.SSLSocketFactory.class} ) + @AndroidOnly("we only have a .bks key store in the test resources") public void testSetDefaultSSLSocketFactory() throws Throwable { // create the SSLServerSocket which will be used by server side SSLContext ctx = getContext(); @@ -320,6 +323,7 @@ public class HttpsURLConnectionTest extends TestCase { method = "setSSLSocketFactory", args = {javax.net.ssl.SSLSocketFactory.class} ) + @AndroidOnly("we only have a .bks key store in the test resources") public void testSetSSLSocketFactory() throws Throwable { // create the SSLServerSocket which will be used by server side SSLContext ctx = getContext(); @@ -399,6 +403,7 @@ public class HttpsURLConnectionTest extends TestCase { args = {} ) }) + @AndroidOnly("we only have a .bks key store in the test resources") public void testUnconnectedStateParameters() throws Throwable { // create HttpsURLConnection to be tested URL url = new URL("https://localhost:55555"); @@ -438,6 +443,7 @@ public class HttpsURLConnectionTest extends TestCase { args = {javax.net.ssl.HostnameVerifier.class} ) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testSetHostnameVerifier() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -487,6 +493,7 @@ public class HttpsURLConnectionTest extends TestCase { args = {boolean.class} ) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void test_doOutput() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -543,6 +550,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testProxyConnection() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -600,6 +608,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testProxyAuthConnection() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -667,6 +676,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testConsequentProxyConnection() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -739,6 +749,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testProxyAuthConnection_doOutput() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -804,6 +815,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testProxyAuthConnectionFailed() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); @@ -866,6 +878,7 @@ public class HttpsURLConnectionTest extends TestCase { ) }) @KnownFailure("VM aborts after more than one test was run.") + @AndroidOnly("we only have a .bks key store in the test resources") public void testProxyConnection_Not_Found_Response() throws Throwable { // setting up the properties pointing to the key/trust stores setUpStoreProperties(); diff --git a/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java b/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java index 44df544..9d477f2 100644 --- a/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java +++ b/luni/src/test/java/tests/api/java/net/DatagramSocketImplTest.java @@ -17,6 +17,7 @@ package tests.api.java.net; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetNew; @@ -226,6 +227,7 @@ public class DatagramSocketImplTest extends junit.framework.TestCase { method = "getLocalPort", args = {} ) + @AndroidOnly("Bug in RI") public void test_getLocalPort() { // RI fails here. RI returns 0. the spec doesn't say what the value for // an unbound DatagramSocket should be. The same difference can be seen diff --git a/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java b/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java index fc9e57d..0272af1 100644 --- a/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java +++ b/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java @@ -25,6 +25,7 @@ import dalvik.annotation.TestTargetNew; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; +import java.security.Permission; import java.util.ArrayList; import java.util.Enumeration; @@ -106,6 +107,9 @@ public class NetworkInterfaceTest extends junit.framework.TestCase { } } + public void checkPermission(Permission perm) { + // allow everything + } } if (atLeastOneInterface) { diff --git a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java index 69f245d..e1f5e86 100755 --- a/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java +++ b/nio/src/test/java/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java @@ -17,7 +17,6 @@ package org.apache.harmony.nio.tests.java.nio.channels; -import dalvik.annotation.KnownFailure; import dalvik.annotation.TestTargets; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargetClass; @@ -27,10 +26,8 @@ import dalvik.annotation.AndroidOnly; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.lang.annotation.Target; import java.net.BindException; import java.net.ConnectException; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; @@ -45,7 +42,6 @@ import java.nio.channels.NoConnectionPendingException; import java.nio.channels.NotYetConnectedException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; -import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.nio.channels.UnresolvedAddressException; @@ -2673,7 +2669,6 @@ public class SocketChannelTest extends TestCase { method = "write", args = {java.nio.ByteBuffer.class} ) - @KnownFailure("Fixed on ToT") public void test_writeLjava_nio_ByteBuffer_Nonblocking_HugeData() throws IOException { // initialize write content ByteBuffer writeContent = ByteBuffer.allocate(CAPACITY_HUGE); diff --git a/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_x_IBM874.java b/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_x_IBM874.java index e538206..ee2bb21 100644 --- a/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_x_IBM874.java +++ b/nio_char/src/test/java/tests/api/java/nio/charset/Charset_SingleByte_x_IBM874.java @@ -33,41 +33,22 @@ public class Charset_SingleByte_x_IBM874 extends Charset_SingleByteAbstractTest allChars = theseChars(new int[]{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 28/*26*/, 27, 127/*28*/, 29, 30, 31, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 26/*127*/, - 65533/*8364*/, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, - 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, 65533, - 3656, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 8364, 129, 130, 131, 132, 8230, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619, 3620, 3621, 3622, 3623, 3624, 3625, 3626, 3627, 3628, 3629, 3630, 3631, - 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 3657, 3658, 3659, 3660, 3647, + 3632, 3633, 3634, 3635, 3636, 3637, 3638, 3639, 3640, 3641, 3642, 63681, 63682, 63683, 63684, 3647, 3648, 3649, 3650, 3651, 3652, 3653, 3654, 3655, 3656, 3657, 3658, 3659, 3660, 3661, 3662, 3663, - 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 162, 172, 166, 160}); + 3664, 3665, 3666, 3667, 3668, 3669, 3670, 3671, 3672, 3673, 3674, 3675, 63685, 63686, 63687, 63688}); super.setUp(); } - -// public static void _test_Bytes_DifferentOnes_RI() throws CharacterCodingException { -// decodeReplace( -// theseBytes(new int[]{26, 28, 127, 128}), -// new char[] {26, 28, 127, 8364} ); -// } - - @TestTargetNew( - level = TestLevel.ADDITIONAL, - method = "functionalCoDec_REPR", - args = {} - ) - public static void test_Bytes_DifferentOnes_Android() throws CharacterCodingException { - // Android: - decodeReplace( - theseBytes(new int[]{26, 28, 127, 128}), - new char[] {28, 127, 26, 65533} ); - } - } diff --git a/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java b/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java index 80f663c..418e52d 100644 --- a/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java +++ b/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java @@ -40,18 +40,25 @@ public class AbstractPreferencesTest extends TestCase { AbstractPreferences pref; - static AbstractPreferences root = (AbstractPreferences) Preferences.userRoot(); + static AbstractPreferences root; static final String nodeName = "mock"; static AbstractPreferences parent = null; + String oldUserHome = System.getProperty("user.home"); + String oldJavaHome = System.getProperty("java.home"); + protected void setUp() throws Exception { super.setUp(); + System.setProperty("user.home", System.getProperty("java.io.tmpdir")); + System.setProperty("java.home", System.getProperty("java.io.tmpdir")); + Preferences.systemRoot().clear(); Preferences.userRoot().clear(); - + + root = (AbstractPreferences) Preferences.userRoot(); parent = (AbstractPreferences) Preferences.userNodeForPackage(this.getClass()); pref = (AbstractPreferences) parent.node(nodeName); @@ -61,6 +68,8 @@ public class AbstractPreferencesTest extends TestCase { parent.removeNode(); Preferences.systemRoot().clear(); Preferences.userRoot().clear(); + System.setProperty("user.home", oldUserHome); + System.setProperty("java.home", oldJavaHome); super.tearDown(); } diff --git a/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java b/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java index 3e1a377..dc2ec2e 100644 --- a/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java +++ b/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java @@ -80,6 +80,7 @@ public class FilePreferencesImplTest extends TestCase { uroot.clear(); names = uroot.keys(); assertEquals(0, names.length); + uroot.removeNode(); } @TestTargets({ @@ -108,6 +109,7 @@ public class FilePreferencesImplTest extends TestCase { assertEquals("value1", sroot.get("skey1", null)); sroot.put("\u4e2d key1", "\u4e2d value1"); assertEquals("\u4e2d value1", sroot.get("\u4e2d key1", null)); + sroot.removeNode(); } @TestTargetNew( @@ -146,6 +148,8 @@ public class FilePreferencesImplTest extends TestCase { assertNotContains(childNames, "child1"); assertNotContains(childNames, "\u4e2d child2"); assertNotContains(childNames, "grand"); + + uroot.removeNode(); } @TestTargetNew( @@ -184,6 +188,7 @@ public class FilePreferencesImplTest extends TestCase { assertNotContains(childNames, "child1"); assertNotContains(childNames, "child2"); assertNotContains(childNames, "grand"); + sroot.removeNode(); } @TestTargets({ @@ -260,6 +265,7 @@ public class FilePreferencesImplTest extends TestCase { } } finally { manager.restoreDefault(); + uroot.removeNode(); } } diff --git a/security/src/test/java/tests/targets/security/CipherHelper.java b/security/src/test/java/tests/targets/security/CipherHelper.java index 2ffdd8a..c31aa20 100644 --- a/security/src/test/java/tests/targets/security/CipherHelper.java +++ b/security/src/test/java/tests/targets/security/CipherHelper.java @@ -2,7 +2,6 @@ package tests.targets.security; import junit.framework.Assert; -import java.io.PrintStream; import java.security.AlgorithmParameters; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -15,7 +14,6 @@ import java.security.PublicKey; import java.security.Signature; import java.security.SignatureException; import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.DSAParameterSpec; import java.security.spec.InvalidParameterSpecException; import java.util.Arrays; @@ -26,9 +24,6 @@ import javax.crypto.KeyAgreement; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; -import javax.crypto.interfaces.DHPrivateKey; -import javax.crypto.interfaces.DHPublicKey; -import javax.crypto.spec.DHParameterSpec; abstract class TestHelper<T/*, U*/> { void test(T testObject) { diff --git a/security/src/test/java/tests/targets/security/DHTest.java b/security/src/test/java/tests/targets/security/DHTest.java index 16b6d62..1c006f1 100644 --- a/security/src/test/java/tests/targets/security/DHTest.java +++ b/security/src/test/java/tests/targets/security/DHTest.java @@ -1,6 +1,5 @@ package tests.targets.security; -import dalvik.annotation.BrokenTest; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; diff --git a/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java b/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java index 940a3aa..8368dad 100644 --- a/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java +++ b/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java @@ -27,7 +27,7 @@ import java.util.jar.JarFile; public class TestHelper_ClassLoader extends ClassLoader { public TestHelper_ClassLoader() { - super(null); + super(); } /** |