Index: modules/security2/test/linux/unit/org/apache/harmony/security/x/security/auth/module/UnixLoginModuleTest.java =================================================================== --- modules/security2/test/linux/unit/org/apache/harmony/security/x/security/auth/module/UnixLoginModuleTest.java (revision 373503) +++ modules/security2/test/linux/unit/org/apache/harmony/security/x/security/auth/module/UnixLoginModuleTest.java (working copy) @@ -28,14 +28,14 @@ import javax.security.auth.callback.Callback; import javax.security.auth.login.LoginException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.x.security.auth.module.UnixLoginModule; /** * Unit test for UnixLoginModule */ -public class UnixLoginModuleTest extends PerformanceTest { +public class UnixLoginModuleTest extends TestCase { /** * Standalone entry point. Index: modules/security2/test/common/unit/java/security/KSCallbackHandlerProtectionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KSCallbackHandlerProtectionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KSCallbackHandlerProtectionTest.java (working copy) @@ -25,14 +25,14 @@ import javax.security.auth.callback.CallbackHandler; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyStore.CallbackHandlerProtection> class constructor and methods * */ -public class KSCallbackHandlerProtectionTest extends PerformanceTest { +public class KSCallbackHandlerProtectionTest extends TestCase { /** * Constructor for KSCallbackHandlerProtectionTest. Index: modules/security2/test/common/unit/java/security/SignedObjectTest.java =================================================================== --- modules/security2/test/common/unit/java/security/SignedObjectTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SignedObjectTest.java (working copy) @@ -26,14 +26,14 @@ import java.util.Properties; import org.apache.harmony.security.TestKeyPair; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SignedObject constructor and methods * */ -public class SignedObjectTest extends PerformanceTest { +public class SignedObjectTest extends TestCase { public void testSignedObject() { Signature sig = null; Index: modules/security2/test/common/unit/java/security/MessageDigestSpiTest.java =================================================================== --- modules/security2/test/common/unit/java/security/MessageDigestSpiTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/MessageDigestSpiTest.java (working copy) @@ -23,14 +23,14 @@ import java.nio.ByteBuffer; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for MessageDigestSpi constructor and methods * */ -public class MessageDigestSpiTest extends PerformanceTest { +public class MessageDigestSpiTest extends TestCase { public void testEngineGetDigestLength() { MyMessageDigest md = new MyMessageDigest(); Index: modules/security2/test/common/unit/java/security/interfaces/DSAPublicKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/DSAPublicKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/DSAPublicKeyTest.java (working copy) @@ -25,13 +25,13 @@ import java.math.BigInteger; import java.security.interfaces.DSAPublicKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DSAPublicKey class field * */ -public class DSAPublicKeyTest extends PerformanceTest { +public class DSAPublicKeyTest extends TestCase { /** * Constructor for DSAPublicKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/ECPublicKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/ECPublicKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/ECPublicKeyTest.java (working copy) @@ -26,13 +26,13 @@ import java.security.interfaces.ECPublicKey; import java.security.spec.ECParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECPublicKey class field * */ -public class ECPublicKeyTest extends PerformanceTest { +public class ECPublicKeyTest extends TestCase { /** * Constructor for ECPublicKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/RSAPrivateCrtKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/RSAPrivateCrtKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/RSAPrivateCrtKeyTest.java (working copy) @@ -25,13 +25,13 @@ import java.math.BigInteger; import java.security.interfaces.RSAPrivateCrtKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAPrivateCrtKey class field * */ -public class RSAPrivateCrtKeyTest extends PerformanceTest { +public class RSAPrivateCrtKeyTest extends TestCase { /** * Constructor for RSAPrivateCrtKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/RSAPrivateKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/RSAPrivateKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/RSAPrivateKeyTest.java (working copy) @@ -25,13 +25,13 @@ import java.math.BigInteger; import java.security.interfaces.RSAPrivateKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAPrivateKey class field * */ -public class RSAPrivateKeyTest extends PerformanceTest { +public class RSAPrivateKeyTest extends TestCase { /** * Constructor for RSAPrivateKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/RSAMultiPrimePrivateCrtKeyTest.java (working copy) @@ -26,13 +26,13 @@ import java.security.interfaces.RSAMultiPrimePrivateCrtKey; import java.security.spec.RSAOtherPrimeInfo; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAMultiPrimePrivateCrtKey class field * */ -public class RSAMultiPrimePrivateCrtKeyTest extends PerformanceTest { +public class RSAMultiPrimePrivateCrtKeyTest extends TestCase { /** * Constructor for RSAMultiPrimePrivateCrtKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/DSAPrivateKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/DSAPrivateKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/DSAPrivateKeyTest.java (working copy) @@ -25,13 +25,13 @@ import java.math.BigInteger; import java.security.interfaces.DSAPrivateKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DSAPrivateKey class field * */ -public class DSAPrivateKeyTest extends PerformanceTest { +public class DSAPrivateKeyTest extends TestCase { /** * Constructor for DSAPrivateKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/ECPrivateKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/ECPrivateKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/ECPrivateKeyTest.java (working copy) @@ -26,13 +26,13 @@ import java.security.interfaces.ECPrivateKey; import java.security.spec.ECParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECPrivateKey class field * */ -public class ECPrivateKeyTest extends PerformanceTest { +public class ECPrivateKeyTest extends TestCase { /** * Constructor for ECPrivateKeyTest. Index: modules/security2/test/common/unit/java/security/interfaces/RSAPublicKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/interfaces/RSAPublicKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/interfaces/RSAPublicKeyTest.java (working copy) @@ -25,13 +25,13 @@ import java.math.BigInteger; import java.security.interfaces.RSAPublicKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAPublicKey class field * */ -public class RSAPublicKeyTest extends PerformanceTest { +public class RSAPublicKeyTest extends TestCase { /** * Constructor for RSAPublicKeyTest. Index: modules/security2/test/common/unit/java/security/KeyManagementExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyManagementExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyManagementExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.KeyManagementException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class KeyManagementExceptionTest extends PerformanceTest { +public class KeyManagementExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testKeyManagementException01() { KeyManagementException tE = new KeyManagementException(); - assertTrue(errNotExc, tE instanceof KeyManagementException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ KeyManagementException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyManagementException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyManagementException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testKeyManagementException03() { String msg = null; KeyManagementException tE = new KeyManagementException(msg); - assertTrue(errNotExc, tE instanceof KeyManagementException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -137,7 +133,6 @@ public void testKeyManagementException04() { Throwable cause = null; KeyManagementException tE = new KeyManagementException(cause); - assertTrue(errNotExc, tE instanceof KeyManagementException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -154,7 +149,6 @@ */ public void testKeyManagementException05() { KeyManagementException tE = new KeyManagementException(tCause); - assertTrue(errNotExc, tE instanceof KeyManagementException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -178,7 +172,6 @@ */ public void testKeyManagementException06() { KeyManagementException tE = new KeyManagementException(null, null); - assertTrue(errNotExc, tE instanceof KeyManagementException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -197,8 +190,6 @@ KeyManagementException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyManagementException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyManagementException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -217,7 +208,6 @@ */ public void testKeyManagementException08() { KeyManagementException tE = new KeyManagementException(null, tCause); - assertTrue(errNotExc, tE instanceof KeyManagementException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -243,8 +233,6 @@ KeyManagementException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyManagementException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyManagementException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/KeyStoreSpiTests.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyStoreSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyStoreSpiTests.java (working copy) @@ -27,7 +27,7 @@ import java.util.Date; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -35,7 +35,7 @@ * */ -public class KeyStoreSpiTests extends PerformanceTest { +public class KeyStoreSpiTests extends TestCase { /** * Constructor for KeyStoreSpi. @@ -62,36 +62,37 @@ public void testKeyStoteSpi01() throws IOException, NoSuchAlgorithmException, CertificateException, UnrecoverableEntryException, KeyStoreException { - KeyStoreSpi ksSpi = (KeyStoreSpi) new MyKeyStoreSpi(); - assertTrue("Not KeyStoreSpi object", ksSpi instanceof KeyStoreSpi); + KeyStoreSpi ksSpi = new MyKeyStoreSpi(); tmpEntry entry = new tmpEntry(); tmpProtection pPar = new tmpProtection(); try { ksSpi.engineLoad(null); } catch (UnsupportedOperationException e) { - logln("UnsupportedOperationException was thrown: " + e.getMessage()); } + try { ksSpi.engineStore(null); } catch (UnsupportedOperationException e) { - logln("UnsupportedOperationException was thrown: " + e.getMessage()); } assertNull("Not null entry", ksSpi.engineGetEntry("aaa", null)); assertNull("Not null entry", ksSpi.engineGetEntry(null, pPar)); assertNull("Not null entry", ksSpi.engineGetEntry("aaa", pPar)); + try { ksSpi.engineSetEntry("", null, null); fail("KeyStoreException or NullPointerException must be thrown"); } catch (KeyStoreException e) { } catch (NullPointerException e) { } + try { ksSpi.engineSetEntry("", new KeyStore.TrustedCertificateEntry( new MyCertificate("type", new byte[0])), null); fail("KeyStoreException must be thrown"); } catch (KeyStoreException e) { } + try { ksSpi.engineSetEntry("aaa", entry, null); fail("KeyStoreException must be thrown"); @@ -107,8 +108,7 @@ */ public void testKeyStoteSpi02() throws NoSuchAlgorithmException, UnrecoverableKeyException, CertificateException { - KeyStoreSpi ksSpi = (KeyStoreSpi) new MyKeyStoreSpi(); - assertTrue("Not KeyStoreSpi object", ksSpi instanceof KeyStoreSpi); + KeyStoreSpi ksSpi = new MyKeyStoreSpi(); assertNull("engineGetKey(..) must return null", ksSpi.engineGetKey("", new char[0])); assertNull("engineGetCertificateChain(..) must return null", ksSpi Index: modules/security2/test/common/unit/java/security/SecureRandomTest1.java =================================================================== --- modules/security2/test/common/unit/java/security/SecureRandomTest1.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SecureRandomTest1.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SecureRandom constructor and methods * */ -public class SecureRandomTest1 extends PerformanceTest { +public class SecureRandomTest1 extends TestCase { /** * SRProvider Index: modules/security2/test/common/unit/java/security/KeyPairGeneratorSpiTests.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyPairGeneratorSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyPairGeneratorSpiTests.java (working copy) @@ -24,14 +24,14 @@ import java.security.spec.AlgorithmParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyPairGeneratorSpi class constructors and methods. * */ -public class KeyPairGeneratorSpiTests extends PerformanceTest { +public class KeyPairGeneratorSpiTests extends TestCase { /** * Constructor for KeyPairGeneratorSpiTests. Index: modules/security2/test/common/unit/java/security/UnresolvedPermissionCollectionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/UnresolvedPermissionCollectionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/UnresolvedPermissionCollectionTest.java (working copy) @@ -23,7 +23,7 @@ import java.util.*; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * */ -public class UnresolvedPermissionCollectionTest extends PerformanceTest { +public class UnresolvedPermissionCollectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(UnresolvedPermissionCollectionTest.class); Index: modules/security2/test/common/unit/java/security/ProtectionDomainTest.java =================================================================== --- modules/security2/test/common/unit/java/security/ProtectionDomainTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/ProtectionDomainTest.java (working copy) @@ -25,7 +25,7 @@ import java.net.MalformedURLException; import java.net.URLClassLoader; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -33,7 +33,7 @@ * */ -public class ProtectionDomainTest extends PerformanceTest { +public class ProtectionDomainTest extends TestCase { /** * Entry point for standalone runs. Index: modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorTest2.java =================================================================== --- modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorTest2.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorTest2.java (working copy) @@ -28,7 +28,7 @@ import java.security.spec.AlgorithmParameterSpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -36,7 +36,7 @@ * methods. */ -public class AlgorithmParameterGeneratorTest2 extends PerformanceTest { +public class AlgorithmParameterGeneratorTest2 extends TestCase { private static final String AlgorithmParameterGeneratorProviderClass = "java.security.MyAlgorithmParameterGeneratorSpi"; @@ -138,8 +138,6 @@ AlgorithmParameterGenerator apG; for (int i = 0; i < validValues.length; i++) { apG = AlgorithmParameterGenerator.getInstance(validValues[i]); - assertTrue("Not instanceof AlgorithmParameterGenerator object", - apG instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", apG.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", apG.getProvider(), mProv); @@ -200,8 +198,6 @@ for (int i = 0; i < validValues.length; i++) { apG = AlgorithmParameterGenerator.getInstance(validValues[i], mProv .getName()); - assertTrue("Not instanceof AlgorithmParameterGenerator object", - apG instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", apG.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", apG.getProvider().getName(), @@ -248,8 +244,6 @@ AlgorithmParameterGenerator apG; for (int i = 0; i < validValues.length; i++) { apG = AlgorithmParameterGenerator.getInstance(validValues[i], mProv); - assertTrue("Not instanceof AlgorithmParameterGenerator object", - apG instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", apG.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", apG.getProvider(), mProv); Index: modules/security2/test/common/unit/java/security/SecurityPermissionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/SecurityPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SecurityPermissionTest.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SecurityPermission * */ -public class SecurityPermissionTest extends PerformanceTest { +public class SecurityPermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(SecurityPermissionTest.class); Index: modules/security2/test/common/unit/java/security/PrivateKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/PrivateKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/PrivateKeyTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.PrivateKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * */ -public class PrivateKeyTest extends PerformanceTest { +public class PrivateKeyTest extends TestCase { /** * Constructor for PrivateKeyTest. Index: modules/security2/test/common/unit/java/security/KeyStoreExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyStoreExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyStoreExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.KeyStoreException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyStoreException class constructors and methods. * */ -public class KeyStoreExceptionTest extends PerformanceTest { +public class KeyStoreExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testKeyStoreException01() { KeyStoreException tE = new KeyStoreException(); - assertTrue(errNotExc, tE instanceof KeyStoreException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ KeyStoreException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyStoreException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyStoreException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testKeyStoreException03() { String msg = null; KeyStoreException tE = new KeyStoreException(msg); - assertTrue(errNotExc, tE instanceof KeyStoreException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -134,7 +130,6 @@ public void testKeyStoreException04() { Throwable cause = null; KeyStoreException tE = new KeyStoreException(cause); - assertTrue(errNotExc, tE instanceof KeyStoreException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -151,7 +146,6 @@ */ public void testKeyStoreException05() { KeyStoreException tE = new KeyStoreException(tCause); - assertTrue(errNotExc, tE instanceof KeyStoreException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -175,7 +169,6 @@ */ public void testKeyStoreException06() { KeyStoreException tE = new KeyStoreException(null, null); - assertTrue(errNotExc, tE instanceof KeyStoreException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -194,8 +187,6 @@ KeyStoreException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyStoreException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyStoreException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -214,7 +205,6 @@ */ public void testKeyStoreException08() { KeyStoreException tE = new KeyStoreException(null, tCause); - assertTrue(errNotExc, tE instanceof KeyStoreException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -240,8 +230,6 @@ KeyStoreException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyStoreException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyStoreException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/GeneralSecurityExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/GeneralSecurityExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/GeneralSecurityExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.GeneralSecurityException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class GeneralSecurityExceptionTest extends PerformanceTest { +public class GeneralSecurityExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testGeneralSecurityException01() { GeneralSecurityException tE = new GeneralSecurityException(); - assertTrue(errNotExc, tE instanceof GeneralSecurityException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ GeneralSecurityException tE; for (int i = 0; i < msgs.length; i++) { tE = new GeneralSecurityException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof GeneralSecurityException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testGeneralSecurityException03() { String msg = null; GeneralSecurityException tE = new GeneralSecurityException(msg); - assertTrue(errNotExc, tE instanceof GeneralSecurityException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -137,7 +133,6 @@ public void testGeneralSecurityException04() { Throwable cause = null; GeneralSecurityException tE = new GeneralSecurityException(cause); - assertTrue(errNotExc, tE instanceof GeneralSecurityException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -154,7 +149,6 @@ */ public void testGeneralSecurityException05() { GeneralSecurityException tE = new GeneralSecurityException(tCause); - assertTrue(errNotExc, tE instanceof GeneralSecurityException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -178,7 +172,6 @@ */ public void testGeneralSecurityException06() { GeneralSecurityException tE = new GeneralSecurityException(null, null); - assertTrue(errNotExc, tE instanceof GeneralSecurityException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -197,8 +190,6 @@ GeneralSecurityException tE; for (int i = 0; i < msgs.length; i++) { tE = new GeneralSecurityException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof GeneralSecurityException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -217,7 +208,6 @@ */ public void testGeneralSecurityException08() { GeneralSecurityException tE = new GeneralSecurityException(null, tCause); - assertTrue(errNotExc, tE instanceof GeneralSecurityException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -243,8 +233,6 @@ GeneralSecurityException tE; for (int i = 0; i < msgs.length; i++) { tE = new GeneralSecurityException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof GeneralSecurityException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/UnrecoverableKeyExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/UnrecoverableKeyExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/UnrecoverableKeyExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.UnrecoverableKeyException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class UnrecoverableKeyExceptionTest extends PerformanceTest { +public class UnrecoverableKeyExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testUnrecoverableKeyException01() { UnrecoverableKeyException tE = new UnrecoverableKeyException(); - assertTrue(errNotExc, tE instanceof UnrecoverableKeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ UnrecoverableKeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new UnrecoverableKeyException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof UnrecoverableKeyException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testUnrecoverableKeyException03() { String msg = null; UnrecoverableKeyException tE = new UnrecoverableKeyException(msg); - assertTrue(errNotExc, tE instanceof UnrecoverableKeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/java/security/NoSuchAlgorithmExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/NoSuchAlgorithmExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/NoSuchAlgorithmExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.NoSuchAlgorithmException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class NoSuchAlgorithmExceptionTest extends PerformanceTest { +public class NoSuchAlgorithmExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testNoSuchAlgorithmException01() { NoSuchAlgorithmException tE = new NoSuchAlgorithmException(); - assertTrue(errNotExc, tE instanceof NoSuchAlgorithmException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ NoSuchAlgorithmException tE; for (int i = 0; i < msgs.length; i++) { tE = new NoSuchAlgorithmException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof NoSuchAlgorithmException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testNoSuchAlgorithmException03() { String msg = null; NoSuchAlgorithmException tE = new NoSuchAlgorithmException(msg); - assertTrue(errNotExc, tE instanceof NoSuchAlgorithmException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -137,7 +133,6 @@ public void testNoSuchAlgorithmException04() { Throwable cause = null; NoSuchAlgorithmException tE = new NoSuchAlgorithmException(cause); - assertTrue(errNotExc, tE instanceof NoSuchAlgorithmException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -154,7 +149,6 @@ */ public void testNoSuchAlgorithmException05() { NoSuchAlgorithmException tE = new NoSuchAlgorithmException(tCause); - assertTrue(errNotExc, tE instanceof NoSuchAlgorithmException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -178,7 +172,6 @@ */ public void testNoSuchAlgorithmException06() { NoSuchAlgorithmException tE = new NoSuchAlgorithmException(null, null); - assertTrue(errNotExc, tE instanceof NoSuchAlgorithmException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -197,8 +190,6 @@ NoSuchAlgorithmException tE; for (int i = 0; i < msgs.length; i++) { tE = new NoSuchAlgorithmException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof NoSuchAlgorithmException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -217,7 +208,6 @@ */ public void testNoSuchAlgorithmException08() { NoSuchAlgorithmException tE = new NoSuchAlgorithmException(null, tCause); - assertTrue(errNotExc, tE instanceof NoSuchAlgorithmException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -243,8 +233,6 @@ NoSuchAlgorithmException tE; for (int i = 0; i < msgs.length; i++) { tE = new NoSuchAlgorithmException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof NoSuchAlgorithmException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/KeyStoreTest3.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyStoreTest3.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyStoreTest3.java (working copy) @@ -31,7 +31,7 @@ import java.security.spec.InvalidKeySpecException; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -39,7 +39,7 @@ * */ -public class KeyStoreTest3 extends PerformanceTest { +public class KeyStoreTest3 extends TestCase { private static final String KeyStoreProviderClass = "java.security.MyKeyStore"; @@ -159,11 +159,13 @@ } catch (IOException e) { } catch (NullPointerException e) { } + try { kss[i].store(bos, null); - logln("store(...) does not throw any exception when password is null"); + fail("store(...) does not throw any exception when password is null"); } catch (IOException e) { } + kss[i].store(bos, pwd); ByteArrayInputStream bis = new ByteArrayInputStream(bos .toByteArray()); Index: modules/security2/test/common/unit/java/security/NoSuchProviderExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/NoSuchProviderExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/NoSuchProviderExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.NoSuchProviderException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class NoSuchProviderExceptionTest extends PerformanceTest { +public class NoSuchProviderExceptionTest extends TestCase { public static void main(String[] args) { } @@ -66,8 +66,6 @@ static Throwable tCause = new Throwable("Throwable for exception"); - private static String errNotExc = "Exception is not NoSuchProviderException"; - static String createErr(Exception tE, Exception eE) { return "NoSuchProvideException: ".concat(tE.toString()).concat( " is not equal to caught exception: ").concat(eE.toString()); @@ -79,7 +77,6 @@ */ public void testNoSuchProviderException01() { NoSuchProviderException tE = new NoSuchProviderException(); - assertTrue(errNotExc, tE instanceof NoSuchProviderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +95,6 @@ NoSuchProviderException tE; for (int i = 0; i < msgs.length; i++) { tE = new NoSuchProviderException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof NoSuchProviderException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +114,6 @@ public void testNoSuchProviderException03() { String msg = null; NoSuchProviderException tE = new NoSuchProviderException(msg); - assertTrue(errNotExc, tE instanceof NoSuchProviderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/java/security/IdentityTest.java =================================================================== --- modules/security2/test/common/unit/java/security/IdentityTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/IdentityTest.java (working copy) @@ -26,14 +26,14 @@ import org.apache.harmony.security.CertificateStub; import org.apache.harmony.security.IdentityStub; import org.apache.harmony.security.PublicKeyStub; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for class Identity * */ -public class IdentityTest extends PerformanceTest { +public class IdentityTest extends TestCase { public static class MySecurityManager extends SecurityManager { public Permissions denied = new Permissions(); @@ -113,8 +113,8 @@ */ public void testToString2() { assertNotNull(new IdentityStub("testToString2").toString()); - logln(new IdentityStub("testToString2").toString()); } + /** * verify Identity() creates instance */ @@ -306,10 +306,10 @@ * verify Identity.toString(boolean) return string represenation of identity */ public void testToStringboolean() throws Exception { - logln(new IdentityStub("aaa").toString(false)); - logln(new IdentityStub("aaa2", IdentityScope.getSystemScope()).toString(false)); - logln(new IdentityStub("bbb").toString(true)); - logln(new IdentityStub("bbb2", IdentityScope.getSystemScope()).toString(true)); + new IdentityStub("aaa").toString(false); + new IdentityStub("aaa2", IdentityScope.getSystemScope()).toString(false); + new IdentityStub("bbb").toString(true); + new IdentityStub("bbb2", IdentityScope.getSystemScope()).toString(true); } /** @@ -319,8 +319,6 @@ Identity i = new IdentityStub("testGetScope"); assertNull(i.getScope()); IdentityScope s = IdentityScope.getSystemScope(); -// s.addIdentity(i); -// assertSame(s, i.getScope()); Identity i2 = new IdentityStub("testGetScope2", s); assertSame(s, i2.getScope()); @@ -351,7 +349,7 @@ */ public void testSetPublicKey2() throws Exception { Identity i2 = new IdentityStub("testSetPublicKey2_2", IdentityScope.getSystemScope()); - PublicKey pk = new PublicKeyStub("kkk", "testSetPublicKey2", new byte[]{1,2,3,4,5}); + new PublicKeyStub("kkk", "testSetPublicKey2", new byte[]{1,2,3,4,5}); try { i2.setPublicKey(null); //fail("KeyManagementException should be thrown - key is null"); @@ -430,8 +428,6 @@ public void testGetInfo() { Identity i = new IdentityStub("testGetInfo"); - //assertNull(i.getInfo()); - logln("testGetInfo: "+i.getInfo()); i.setInfo("some info"); assertEquals("some info", i.getInfo()); } Index: modules/security2/test/common/unit/java/security/KeyPairGeneratorTest1.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyPairGeneratorTest1.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyPairGeneratorTest1.java (working copy) @@ -26,14 +26,14 @@ import java.security.spec.AlgorithmParameterSpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyPairGenerator class constructors and methods. * */ -public class KeyPairGeneratorTest1 extends PerformanceTest { +public class KeyPairGeneratorTest1 extends TestCase { /** * Constructor for KayPairGeneratorTest. @@ -124,8 +124,6 @@ KeyPairGenerator kpg; for (int i = 0; i < algs.length; i++) { kpg = KeyPairGenerator.getInstance(algs[i]); - assertTrue("Not KeyPairGenerator object", - kpg instanceof KeyPairGenerator); assertEquals("Incorrect algorithm ", kpg.getAlgorithm().toUpperCase(), algs[i].toUpperCase()); } @@ -227,8 +225,6 @@ KeyPairGenerator kpg; for (int i = 0; i < algs.length; i++) { kpg = KeyPairGenerator.getInstance(algs[i], validProviderName); - assertTrue("Not KeyPairGenerator object", - kpg instanceof KeyPairGenerator); assertEquals("Incorrect algorithm", kpg.getAlgorithm().toUpperCase(), algs[i].toUpperCase()); assertEquals("Incorrect provider", kpg.getProvider().getName(), @@ -299,8 +295,6 @@ KeyPairGenerator kpg; for (int i = 0; i < algs.length; i++) { kpg = KeyPairGenerator.getInstance(algs[i], validProvider); - assertTrue("Not KeyPairGenerator object", - kpg instanceof KeyPairGenerator); assertEquals("Incorrect algorithm", kpg.getAlgorithm().toUpperCase(), algs[i].toUpperCase()); assertEquals("Incorrect provider", kpg.getProvider(), validProvider); @@ -325,10 +319,8 @@ for (int i = 0; i < kpg.length; i++) { kpg[i].initialize(512); kp = kpg[i].generateKeyPair(); - assertTrue("Not KeyPair object", kp instanceof KeyPair); kp1 = kpg[i].genKeyPair(); - assertTrue("Not KeyPair object", kp1 instanceof KeyPair); assertFalse("Incorrect private key", kp.getPrivate().equals( kp1.getPrivate())); assertFalse("Incorrect public key", kp.getPublic().equals( @@ -357,32 +349,20 @@ assertNotNull("KeyPairGenerator objects were not created", kpg); SecureRandom random = new SecureRandom(); AlgorithmParameterSpec aps = null; + for (int i = 0; i < kpg.length; i++) { for (int j = 0; j < keys.length; j++) { try { kpg[i].initialize(keys[j]); - logln("Ignore keysize:" + Integer.toString(keys[j])); - } catch (InvalidParameterException e) { - } catch (IllegalArgumentException e) { - } - - try { kpg[i].initialize(keys[j], random); - logln("Ignore keysize:" + Integer.toString(keys[j]) - + " with non-null random"); } catch (InvalidParameterException e) { - } catch (IllegalArgumentException e) { } } + try { kpg[i].initialize(aps); - logln("Ignore null AlgorithmParameterSpec"); - } catch (InvalidAlgorithmParameterException e) { - } - try { kpg[i].initialize(aps, random); - logln("Ignore null AlgorithmParameterSpec"); } catch (InvalidAlgorithmParameterException e) { } } @@ -404,16 +384,12 @@ int[] keys = { -1, -250, 1, 64, 512, 1024 }; SecureRandom random = new SecureRandom(); AlgorithmParameterSpec aps; - KeyPairGenerator mKPG = (KeyPairGenerator) new MyKeyPairGenerator1(""); - assertTrue("Not KeyPairGenerator object", - mKPG instanceof KeyPairGenerator); + KeyPairGenerator mKPG = new MyKeyPairGenerator1(""); assertEquals("Incorrect algorithm", mKPG.getAlgorithm(), MyKeyPairGenerator1.getResAlgorithm()); - KeyPair kp = mKPG.generateKeyPair(); - assertTrue("Not KeyPair object", kp instanceof KeyPair); - kp = mKPG.genKeyPair(); - assertTrue("Not KeyPair object", kp instanceof KeyPair); + mKPG.generateKeyPair(); + mKPG.genKeyPair(); for (int i = 0; i < keys.length; i++) { try { @@ -483,9 +459,7 @@ public void testKeyPairGenerator13() { int[] keys = { -1, -250, 1, 63, -512, -1024 }; SecureRandom random = new SecureRandom(); - KeyPairGenerator mKPG = (KeyPairGenerator) new MyKeyPairGenerator2(null); - assertTrue("Not KeyPairGenerator object", - mKPG instanceof KeyPairGenerator); + KeyPairGenerator mKPG = new MyKeyPairGenerator2(null); assertEquals("Algorithm must be null", mKPG.getAlgorithm(), MyKeyPairGenerator2.getResAlgorithm()); assertNull("genKeyPair() must return null", mKPG.genKeyPair()); Index: modules/security2/test/common/unit/java/security/UnrecoverableEntryExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/UnrecoverableEntryExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/UnrecoverableEntryExceptionTest.java (working copy) @@ -21,14 +21,14 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for UnrecoverableEntryException class * */ -public class UnrecoverableEntryExceptionTest extends PerformanceTest { +public class UnrecoverableEntryExceptionTest extends TestCase { /** * Constructor for UnrecoverableEntryExceptionTest. Index: modules/security2/test/common/unit/java/security/TimestampTest.java =================================================================== --- modules/security2/test/common/unit/java/security/TimestampTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/TimestampTest.java (working copy) @@ -25,7 +25,7 @@ import java.util.Date; import org.apache.harmony.security.cert.MyCertPath; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -33,7 +33,7 @@ * */ -public class TimestampTest extends PerformanceTest { +public class TimestampTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(TimestampTest.class); Index: modules/security2/test/common/unit/java/security/MessageDigestTest1.java =================================================================== --- modules/security2/test/common/unit/java/security/MessageDigestTest1.java (revision 373503) +++ modules/security2/test/common/unit/java/security/MessageDigestTest1.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for MessageDigest constructor and methods * */ -public class MessageDigestTest1 extends PerformanceTest { +public class MessageDigestTest1 extends TestCase { public void testReset() { MyMessageDigest1 md = new MyMessageDigest1("ABC"); Index: modules/security2/test/common/unit/java/security/InvalidParameterExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/InvalidParameterExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/InvalidParameterExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.InvalidParameterException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class InvalidParameterExceptionTest extends PerformanceTest { +public class InvalidParameterExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testInvalidParameterException01() { InvalidParameterException tE = new InvalidParameterException(); - assertTrue(errNotExc, tE instanceof InvalidParameterException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ InvalidParameterException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidParameterException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidParameterException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testInvalidParameterException03() { String msg = null; InvalidParameterException tE = new InvalidParameterException(msg); - assertTrue(errNotExc, tE instanceof InvalidParameterException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/java/security/KeyExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.KeyException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyException class constructors and methods. * */ -public class KeyExceptionTest extends PerformanceTest { +public class KeyExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testKeyException01() { KeyException tE = new KeyException(); - assertTrue(errNotExc, tE instanceof KeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ KeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testKeyException03() { String msg = null; KeyException tE = new KeyException(msg); - assertTrue(errNotExc, tE instanceof KeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -134,7 +130,6 @@ public void testKeyException04() { Throwable cause = null; KeyException tE = new KeyException(cause); - assertTrue(errNotExc, tE instanceof KeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -150,7 +145,6 @@ */ public void testKeyException05() { KeyException tE = new KeyException(tCause); - assertTrue(errNotExc, tE instanceof KeyException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -174,7 +168,6 @@ */ public void testKeyException06() { KeyException tE = new KeyException(null, null); - assertTrue(errNotExc, tE instanceof KeyException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -193,8 +186,6 @@ KeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -213,7 +204,6 @@ */ public void testKeyException08() { KeyException tE = new KeyException(null, tCause); - assertTrue(errNotExc, tE instanceof KeyException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -239,8 +229,6 @@ KeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new KeyException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof KeyException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/KSPasswordProtectionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KSPasswordProtectionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KSPasswordProtectionTest.java (working copy) @@ -24,14 +24,14 @@ import javax.security.auth.DestroyFailedException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyStore.PasswordProtection class constructor and methods * */ -public class KSPasswordProtectionTest extends PerformanceTest { +public class KSPasswordProtectionTest extends TestCase { /** * Constructor for KSPasswordProtectionTest. Index: modules/security2/test/common/unit/java/security/SecureRandomTest2.java =================================================================== --- modules/security2/test/common/unit/java/security/SecureRandomTest2.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SecureRandomTest2.java (working copy) @@ -23,7 +23,7 @@ import java.util.Random; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * Tests for internal Secure Random implementation based on Random * */ -public class SecureRandomTest2 extends PerformanceTest { +public class SecureRandomTest2 extends TestCase { /** * Registered providers Index: modules/security2/test/common/unit/java/security/ProviderServiceTest.java =================================================================== --- modules/security2/test/common/unit/java/security/ProviderServiceTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/ProviderServiceTest.java (working copy) @@ -23,14 +23,14 @@ import java.util.HashMap; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for Provider.Service constructor and methods * */ -public class ProviderServiceTest extends PerformanceTest { +public class ProviderServiceTest extends TestCase { public void testService() { Provider p = new MyProvider(); Index: modules/security2/test/common/unit/java/security/AllPermissionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/AllPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AllPermissionTest.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for AllPermission * */ -public class AllPermissionTest extends PerformanceTest { +public class AllPermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AllPermissionTest.class); Index: modules/security2/test/common/unit/java/security/SignatureTest1.java =================================================================== --- modules/security2/test/common/unit/java/security/SignatureTest1.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SignatureTest1.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for Signature constructor and methods * */ -public class SignatureTest1 extends PerformanceTest { +public class SignatureTest1 extends TestCase { /* * Class under test for Object clone() Index: modules/security2/test/common/unit/java/security/KSBuilderTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KSBuilderTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KSBuilderTest.java (working copy) @@ -34,7 +34,7 @@ import org.apache.harmony.security.SpiEngUtils; import org.apache.harmony.security.TestKeyPair; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.test.TestUtils; /** @@ -42,7 +42,7 @@ * */ -public class KSBuilderTest extends PerformanceTest { +public class KSBuilderTest extends TestCase { /** * Constructor for KSBuilderTest * @@ -63,8 +63,6 @@ private static boolean JKSSupported = false; - private static String defaultProviderName = null; - private static Provider defaultProvider = null; private static String fileEmpty = "java/security/KSEmpty.dat"; @@ -75,7 +73,6 @@ defaultProvider = SpiEngUtils.isSupport( KeyStoreTest1.defaultType, KeyStoreTest1.srvKeyStore); JKSSupported = (defaultProvider != null); - defaultProviderName = (JKSSupported ? defaultProvider.getName() : null); fileEmpty = SpiEngUtils.getFileName(TestUtils.TEST_ROOT, fileEmpty); fileName = SpiEngUtils.getFileName(TestUtils.TEST_ROOT, @@ -194,15 +191,11 @@ } ks.load(null, pass); ksB = KeyStore.Builder.newInstance(ks, pp[i]); - assertTrue("Not KeyStore.Builder object with empty KeyStore", - ksB instanceof KeyStore.Builder); assertEquals("Incorrect KeyStore", ksB.getKeyStore().size(), 0); ks.setEntry("aaa", pKey, pp[0]); ksB = KeyStore.Builder.newInstance(ks, pp[i]); - assertTrue("Not KeyStore.Builder object", - ksB instanceof KeyStore.Builder); // verification getKeyStore() and getProtectionParameter(String // alias) @@ -218,18 +211,22 @@ } catch (KeyStoreException e) { fail("Unexpected: " + e.toString() + " was thrown"); } + try { assertEquals(ksB.getProtectionParameter("Bad alias"), pp[i]); } catch (KeyStoreException e) { - logln("KeyStoreException was thrown because there is no entry with such alias"); + // KeyStoreException might be thrown because there is no entry with such alias } + try { assertEquals(ksB.getProtectionParameter(""), pp[i]); } catch (KeyStoreException e) { - logln("KeyStoreException was thrown because there is no entry with such alias"); + // KeyStoreException might be thrown because there is no entry with such alias } + KeyStore.ProtectionParameter pPar = ksB .getProtectionParameter("aaa"); + switch (i) { case 0: assertTrue(pPar instanceof KeyStore.PasswordProtection); @@ -324,8 +321,6 @@ } ksB = KeyStore.Builder.newInstance(defaultType, defaultProvider, fl, protPass); - assertTrue("Not KeyStore.Builder object", - ksB instanceof KeyStore.Builder); try { ksB.getKeyStore(); fail("KeyStoreException must be throw because file is empty"); @@ -353,10 +348,6 @@ ksB = KeyStore.Builder.newInstance(defaultType, null, fl, pp[i]); ksB1 = KeyStore.Builder.newInstance(defaultType, defaultProvider, fl, pp[i]); - assertTrue("Incorrect KeyStore.Builder", - ksB instanceof KeyStore.Builder); - assertTrue("Incorrect KeyStore.Builder", - ksB1 instanceof KeyStore.Builder); try { ks = ksB.getKeyStore(); if (i == 2) { @@ -367,9 +358,8 @@ } catch (KeyStoreException e) { if (i == 2) { continue; - } else { - fail("Unexpected KeyException was thrown"); } + fail("Unexpected KeyException was thrown"); } try { ks1 = ksB1.getKeyStore(); @@ -379,13 +369,13 @@ } catch (KeyStoreException e) { if (i == 2) { continue; - } else { - fail("Unexpected KeyException was thrown"); } + fail("Unexpected KeyException was thrown"); } assertEquals("Incorrect KeyStore size", ks.size(), ks1.size()); Enumeration iter = ks.aliases(); String aName; + while (iter.hasMoreElements()) { aName = (String) iter.nextElement(); try { @@ -396,11 +386,13 @@ + " was thrown for alias: " + aName); } } + try { assertEquals(ksB.getProtectionParameter("Bad alias"), pp[i]); } catch (KeyStoreException e) { - logln("KeyStoreException was thrown because there is no entry with such alias"); + // KeyStoreException might be thrown because there is no entry with such alias } + iter = ks1.aliases(); while (iter.hasMoreElements()) { aName = (String) iter.nextElement(); @@ -412,10 +404,11 @@ + " was thrown for alias: " + aName); } } + try { assertEquals(ksB1.getProtectionParameter("Bad alias"), pp[i]); } catch (KeyStoreException e) { - logln("KeyStoreException was thrown because there is no entry with such alias"); + // KeyStoreException might be thrown because there is no entry with such alias } } } @@ -443,13 +436,13 @@ return; } try { - KeyStore.Builder ksB = KeyStore.Builder.newInstance(null, + KeyStore.Builder.newInstance(null, defaultProvider, protPass); fail("NullPointerException must be thrown when type is null"); } catch (NullPointerException e) { } try { - KeyStore.Builder ksB = KeyStore.Builder.newInstance(defaultType, + KeyStore.Builder.newInstance(defaultType, defaultProvider, null); fail("NullPointerException must be thrown when ProtectionParameter is null"); } catch (NullPointerException e) { @@ -464,7 +457,6 @@ ksB1 = KeyStore.Builder.newInstance(defaultType, null, pp[i]); switch (i) { case 0: - Exception ex1 = null; try { ks = ksB.getKeyStore(); assertNotNull("KeyStore is null", ks); @@ -472,31 +464,30 @@ assertEquals(ksB.getProtectionParameter("Bad alias"), pp[i]); } catch (KeyStoreException e) { - logln("KeyStoreException was thrown because there is no entry in key store"); + // KeyStoreException might be thrown because there is no entry with such alias } + ks = ksB1.getKeyStore(); assertNotNull("KeyStore is null", ks); + try { assertEquals(ksB1.getProtectionParameter("Bad alias"), pp[i]); } catch (KeyStoreException e) { - logln("KeyStoreException must was thrown because there is no entry in key store"); + // KeyStoreException might be thrown because there is no entry with such alias } } catch (KeyStoreException e) { - ex1 = e; - } - if (ex1 != null) { try { ks = ksB.getKeyStore(); - } catch (KeyStoreException e) { - assertEquals("Incorrect exception", ex1.getMessage(), e + } catch (KeyStoreException e1) { + assertEquals("Incorrect exception", e.getMessage(), e1 .getMessage()); } } break; case 1: case 2: - ex1 = null; + Exception ex1 = null; Exception ex2 = null; try { ks = ksB.getKeyStore(); @@ -510,11 +501,14 @@ } assertEquals("Incorrect exception", ex1.getMessage(), ex2 .getMessage()); + + try { ksB.getProtectionParameter("aaa"); fail("IllegalStateException must be thrown because getKeyStore() was not invoked"); } catch (IllegalStateException e) { } + try { ks = ksB1.getKeyStore(); } catch (KeyStoreException e) { @@ -527,6 +521,8 @@ } assertEquals("Incorrect exception", ex1.getMessage(), ex2 .getMessage()); + + try { ksB1.getProtectionParameter("aaa"); fail("IllegalStateException must be thrown because getKeyStore() was not invoked"); @@ -595,11 +591,9 @@ * Additional class for creating KeyStoreBuilder */ class myProtectionParameter implements KeyStore.ProtectionParameter { - private byte [] myPPParam; public myProtectionParameter(byte [] param) { if (param == null) { throw new NullPointerException("param is null"); } - myPPParam = param; } } \ No newline at end of file Index: modules/security2/test/common/unit/java/security/PublicKeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/PublicKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/PublicKeyTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.PublicKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * */ -public class PublicKeyTest extends PerformanceTest { +public class PublicKeyTest extends TestCase { /** Index: modules/security2/test/common/unit/java/security/KeyPairGeneratorTest2.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyPairGeneratorTest2.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyPairGeneratorTest2.java (working copy) @@ -28,7 +28,7 @@ import java.security.spec.AlgorithmParameterSpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -36,7 +36,7 @@ * */ -public class KeyPairGeneratorTest2 extends PerformanceTest { +public class KeyPairGeneratorTest2 extends TestCase { private String KeyPairGeneratorProviderClass = ""; private static final String KeyPairGeneratorProviderClass1 = "java.security.MyKeyPairGenerator1"; @@ -113,8 +113,8 @@ assertEquals("Incorrect exception", e.getMessage(), "Incorrect random"); } - assertTrue("Not KeyPair object", keyPairGen.generateKeyPair() instanceof KeyPair); - assertTrue("Not KeyPair object", keyPairGen.genKeyPair() instanceof KeyPair); + keyPairGen.generateKeyPair(); + keyPairGen.genKeyPair(); break; case 2: try { @@ -133,26 +133,11 @@ assertNull("Not null KeyPair", keyPairGen.genKeyPair()); break; case 3: - try { - keyPairGen.initialize(pp, new SecureRandom()); - logln("Method initialize(AlgorithmParameterSpec, SecureRandom) is supported"); - } catch (UnsupportedOperationException e) { - } - try { - keyPairGen.initialize(pp); - logln("Method initialize(AlgorithmParameterSpec) is supported"); - } catch (UnsupportedOperationException e) { - } - try { - keyPairGen.initialize(1000, new SecureRandom()); - logln("Method initialize(int, SecureRandom) is supported"); - } catch (UnsupportedOperationException e) { - } - try { - keyPairGen.initialize(100); - logln("Method initialize(int) is supported"); - } catch (UnsupportedOperationException e) { - } + keyPairGen.initialize(pp, new SecureRandom()); + keyPairGen.initialize(pp); + keyPairGen.initialize(1000, new SecureRandom()); + keyPairGen.initialize(100); + assertNotNull("Null KeyPair", keyPairGen.generateKeyPair()); assertNotNull("Null KeyPair", keyPairGen.genKeyPair()); break; @@ -219,8 +204,6 @@ for (int i = 0; i < validValues.length; i++) { String alg = validValues[i].concat(post); kpG = KeyPairGenerator.getInstance(alg); - assertTrue("Not instanceof KeyPairGenerator object", - kpG instanceof KeyPairGenerator); assertEquals("Incorrect algorithm", kpG.getAlgorithm() .toUpperCase(), (mode <= 2 ? resAlg : alg).toUpperCase()); assertEquals("Incorrect provider", kpG.getProvider(), mProv); @@ -282,8 +265,6 @@ for (int i = 0; i < validValues.length; i++) { String alg = validValues[i].concat(post); kpG = KeyPairGenerator.getInstance(alg, mProv.getName()); - assertTrue("Not instanceof KeyPairGenerator object", - kpG instanceof KeyPairGenerator); assertEquals("Incorrect algorithm", kpG.getAlgorithm() .toUpperCase(), (mode <= 2 ? resAlg : alg).toUpperCase()); assertEquals("Incorrect provider", kpG.getProvider().getName(), @@ -331,8 +312,6 @@ for (int i = 0; i < validValues.length; i++) { String alg = validValues[i].concat(post); kpG = KeyPairGenerator.getInstance(alg, mProv); - assertTrue("Not instanceof KeyPairGenerator object", - kpG instanceof KeyPairGenerator); assertEquals("Incorrect algorithm", kpG.getAlgorithm() .toUpperCase(), (mode <= 2 ? resAlg : alg).toUpperCase()); assertEquals("Incorrect provider", kpG.getProvider(), mProv); Index: modules/security2/test/common/unit/java/security/GuardedObjectTest.java =================================================================== --- modules/security2/test/common/unit/java/security/GuardedObjectTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/GuardedObjectTest.java (working copy) @@ -21,14 +21,14 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for GuardedObject * */ -public class GuardedObjectTest extends PerformanceTest { +public class GuardedObjectTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(GuardedObjectTest.class); Index: modules/security2/test/common/unit/java/security/SecureClassLoaderTest.java =================================================================== --- modules/security2/test/common/unit/java/security/SecureClassLoaderTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SecureClassLoaderTest.java (working copy) @@ -26,7 +26,7 @@ import java.nio.ByteBuffer; import java.security.cert.Certificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -34,7 +34,7 @@ * */ -public class SecureClassLoaderTest extends PerformanceTest { +public class SecureClassLoaderTest extends TestCase { /** * Entry point for stand alone runs. * Index: modules/security2/test/common/unit/java/security/BasicPermissionCollectionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/BasicPermissionCollectionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/BasicPermissionCollectionTest.java (working copy) @@ -31,7 +31,7 @@ import java.util.Collection; import java.util.Enumeration; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -39,7 +39,7 @@ * */ -public class BasicPermissionCollectionTest extends PerformanceTest { +public class BasicPermissionCollectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(BasicPermissionCollectionTest.class); Index: modules/security2/test/common/unit/java/security/MessageDigestTest2.java =================================================================== --- modules/security2/test/common/unit/java/security/MessageDigestTest2.java (revision 373503) +++ modules/security2/test/common/unit/java/security/MessageDigestTest2.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for MessageDigest constructor and methods * */ -public class MessageDigestTest2 extends PerformanceTest { +public class MessageDigestTest2 extends TestCase { /** * Provider Index: modules/security2/test/common/unit/java/security/ProviderExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/ProviderExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/ProviderExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.ProviderException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ProviderException class constructors and methods. * */ -public class ProviderExceptionTest extends PerformanceTest { +public class ProviderExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testProviderException01() { ProviderException tE = new ProviderException(); - assertTrue(errNotExc, tE instanceof ProviderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ ProviderException tE; for (int i = 0; i < msgs.length; i++) { tE = new ProviderException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof ProviderException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testProviderException03() { String msg = null; ProviderException tE = new ProviderException(msg); - assertTrue(errNotExc, tE instanceof ProviderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -134,7 +130,6 @@ public void testProviderException04() { Throwable cause = null; ProviderException tE = new ProviderException(cause); - assertTrue(errNotExc, tE instanceof ProviderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -151,7 +146,6 @@ */ public void testProviderException05() { ProviderException tE = new ProviderException(tCause); - assertTrue(errNotExc, tE instanceof ProviderException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -175,7 +169,6 @@ */ public void testProviderException06() { ProviderException tE = new ProviderException(null, null); - assertTrue(errNotExc, tE instanceof ProviderException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -194,8 +187,6 @@ ProviderException tE; for (int i = 0; i < msgs.length; i++) { tE = new ProviderException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof ProviderException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -214,7 +205,6 @@ */ public void testProviderException08() { ProviderException tE = new ProviderException(null, tCause); - assertTrue(errNotExc, tE instanceof ProviderException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -240,8 +230,6 @@ ProviderException tE; for (int i = 0; i < msgs.length; i++) { tE = new ProviderException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof ProviderException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/AlgorithmParametersTest.java =================================================================== --- modules/security2/test/common/unit/java/security/AlgorithmParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AlgorithmParametersTest.java (working copy) @@ -21,14 +21,14 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for AlgorithmParameters class constructors and * methods. * */ -public class AlgorithmParametersTest extends PerformanceTest { +public class AlgorithmParametersTest extends TestCase { /** * Provider Index: modules/security2/test/common/unit/java/security/DigestInputStreamTest.java =================================================================== --- modules/security2/test/common/unit/java/security/DigestInputStreamTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/DigestInputStreamTest.java (working copy) @@ -32,13 +32,13 @@ import java.util.Arrays; import org.apache.harmony.security.MDGoldenData; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for fields and methods of class DigestInputStream * */ -public class DigestInputStreamTest extends PerformanceTest { +public class DigestInputStreamTest extends TestCase { /** * Message digest algorithm name used during testing @@ -232,9 +232,7 @@ * InputStream not set. read() must * not work */ - public final void testRead04() - throws IOException { - boolean passed = false; + public final void testRead04() throws IOException { for (int ii=0; iiread() must not work when digest * functionality is on */ - public final void testRead05() - throws IOException { - boolean passed = false; + public final void testRead05() { InputStream is = new ByteArrayInputStream(myMessage); DigestInputStream dis = new DigestInputStream(is, null); + // must result in an exception try { for (int i=0; iDigestInputStream * */ -public class DigestOutputStreamTest extends PerformanceTest { +public class DigestOutputStreamTest extends TestCase { /** * Message digest algorithm name used during testing @@ -194,9 +194,7 @@ * OutputStream not set. write(int) must * not work */ - public final void testWriteint03() - throws IOException { - boolean passed = false; + public final void testWriteint03() throws IOException { for (int k=0; kwrite(int) must not work when digest * functionality is on */ - public final void testWriteint04() - throws IOException { - boolean passed = false; + public final void testWriteint04() throws IOException { OutputStream os = new ByteArrayOutputStream(MY_MESSAGE_LEN); DigestOutputStream dos = new DigestOutputStream(os, null); + // must result in an exception try { for (int i=0; iwrite(int) must work when digest * functionality is off */ - public final void testWriteint05() - throws IOException { + public final void testWriteint05() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN); DigestOutputStream dos = new DigestOutputStream(bos, null); // set digest functionality to off @@ -507,9 +500,8 @@ ByteArrayOutputStream bos = new ByteArrayOutputStream(MY_MESSAGE_LEN); MessageDigest md = MessageDigest.getInstance(algorithmName[k]); DigestOutputStream dos = new DigestOutputStream(bos, md); - String rep = dos.toString(); - logln(getName() + ": " + rep); - assertTrue(rep != null); + + assertNotNull(dos.toString()); return; } catch (NoSuchAlgorithmException e) { // allowed failure Index: modules/security2/test/common/unit/java/security/KSTrustedCertificateEntryTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KSTrustedCertificateEntryTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KSTrustedCertificateEntryTest.java (working copy) @@ -24,14 +24,14 @@ import java.security.cert.Certificate; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyStore.TrustedCertificateEntry class constructor and methods * */ -public class KSTrustedCertificateEntryTest extends PerformanceTest { +public class KSTrustedCertificateEntryTest extends TestCase { /** * Test for KeyStore.TrustedCertificateEntry(Certificate trustCert) @@ -55,8 +55,6 @@ Certificate cert = new MyCertificate("TEST", new byte[10]); KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert); - assertTrue("Not KeyStore.TrustedCertificateEntry object", - ksTCE instanceof KeyStore.TrustedCertificateEntry); assertEquals("Incorrect certificate", cert, ksTCE.getTrustedCertificate()); } @@ -68,9 +66,6 @@ Certificate cert = new MyCertificate("TEST", new byte[10]); KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert); - assertTrue("Not KeyStore.TrustedCertificateEntry object", - ksTCE instanceof KeyStore.TrustedCertificateEntry); assertNotNull("toString() returns null string", ksTCE.toString()); - logln(ksTCE.toString()); } } Index: modules/security2/test/common/unit/java/security/InvalidAlgorithmParameterExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/InvalidAlgorithmParameterExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/InvalidAlgorithmParameterExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.InvalidAlgorithmParameterException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * constructors and methods. * */ -public class InvalidAlgorithmParameterExceptionTest extends PerformanceTest { +public class InvalidAlgorithmParameterExceptionTest extends TestCase { public static void main(String[] args) { } @@ -81,7 +81,6 @@ */ public void testInvalidAlgorithmParameterException01() { InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException(); - assertTrue(errNotExc, tE instanceof InvalidAlgorithmParameterException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -100,8 +99,6 @@ InvalidAlgorithmParameterException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidAlgorithmParameterException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidAlgorithmParameterException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -122,7 +119,6 @@ String msg = null; InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException( msg); - assertTrue(errNotExc, tE instanceof InvalidAlgorithmParameterException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -141,7 +137,6 @@ Throwable cause = null; InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException( cause); - assertTrue(errNotExc, tE instanceof InvalidAlgorithmParameterException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -159,7 +154,6 @@ public void testInvalidAlgorithmParameterException05() { InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException( tCause); - assertTrue(errNotExc, tE instanceof InvalidAlgorithmParameterException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -185,7 +179,6 @@ public void testInvalidAlgorithmParameterException06() { InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException( null, null); - assertTrue(errNotExc, tE instanceof InvalidAlgorithmParameterException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -205,8 +198,6 @@ InvalidAlgorithmParameterException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidAlgorithmParameterException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidAlgorithmParameterException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -227,7 +218,6 @@ public void testInvalidAlgorithmParameterException08() { InvalidAlgorithmParameterException tE = new InvalidAlgorithmParameterException( null, tCause); - assertTrue(errNotExc, tE instanceof InvalidAlgorithmParameterException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -254,8 +244,6 @@ InvalidAlgorithmParameterException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidAlgorithmParameterException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidAlgorithmParameterException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CRLExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CRLExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CRLExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.cert.CRLException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for CRLException class constructors and methods. * */ -public class CRLExceptionTest extends PerformanceTest { +public class CRLExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCRLException01() { CRLException tE = new CRLException(); - assertTrue(errNotExc, tE instanceof CRLException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CRLException tE; for (int i = 0; i < msgs.length; i++) { tE = new CRLException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CRLException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testCRLException03() { String msg = null; CRLException tE = new CRLException(msg); - assertTrue(errNotExc, tE instanceof CRLException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -134,7 +130,6 @@ public void testCRLException04() { Throwable cause = null; CRLException tE = new CRLException(cause); - assertTrue(errNotExc, tE instanceof CRLException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -150,7 +145,6 @@ */ public void testCRLException05() { CRLException tE = new CRLException(tCause); - assertTrue(errNotExc, tE instanceof CRLException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -174,7 +168,6 @@ */ public void testCRLException06() { CRLException tE = new CRLException(null, null); - assertTrue(errNotExc, tE instanceof CRLException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -193,8 +186,6 @@ CRLException tE; for (int i = 0; i < msgs.length; i++) { tE = new CRLException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CRLException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -213,7 +204,6 @@ */ public void testCRLException08() { CRLException tE = new CRLException(null, tCause); - assertTrue(errNotExc, tE instanceof CRLException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -239,8 +229,6 @@ CRLException tE; for (int i = 0; i < msgs.length; i++) { tE = new CRLException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CRLException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CertPathBuilderExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertPathBuilderExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertPathBuilderExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.cert.CertPathBuilderException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class CertPathBuilderExceptionTest extends PerformanceTest { +public class CertPathBuilderExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testCertPathBuilderException01() { CertPathBuilderException tE = new CertPathBuilderException(); - assertTrue(errNotExc, tE instanceof CertPathBuilderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ CertPathBuilderException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertPathBuilderException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertPathBuilderException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testCertPathBuilderException03() { String msg = null; CertPathBuilderException tE = new CertPathBuilderException(msg); - assertTrue(errNotExc, tE instanceof CertPathBuilderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -137,7 +133,6 @@ public void testCertPathBuilderException04() { Throwable cause = null; CertPathBuilderException tE = new CertPathBuilderException(cause); - assertTrue(errNotExc, tE instanceof CertPathBuilderException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -154,7 +149,6 @@ */ public void testCertPathBuilderException05() { CertPathBuilderException tE = new CertPathBuilderException(tCause); - assertTrue(errNotExc, tE instanceof CertPathBuilderException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -178,7 +172,6 @@ */ public void testCertPathBuilderException06() { CertPathBuilderException tE = new CertPathBuilderException(null, null); - assertTrue(errNotExc, tE instanceof CertPathBuilderException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -197,8 +190,6 @@ CertPathBuilderException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertPathBuilderException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertPathBuilderException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -217,7 +208,6 @@ */ public void testCertPathBuilderException08() { CertPathBuilderException tE = new CertPathBuilderException(null, tCause); - assertTrue(errNotExc, tE instanceof CertPathBuilderException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -243,8 +233,6 @@ CertPathBuilderException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertPathBuilderException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertPathBuilderException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CertificateExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.cert.CertificateException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for CertificateException class constructors and methods. * */ -public class CertificateExceptionTest extends PerformanceTest { +public class CertificateExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertificateException01() { CertificateException tE = new CertificateException(); - assertTrue(errNotExc, tE instanceof CertificateException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertificateException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testCertificateException03() { String msg = null; CertificateException tE = new CertificateException(msg); - assertTrue(errNotExc, tE instanceof CertificateException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -136,7 +132,6 @@ public void testCertificateException04() { Throwable cause = null; CertificateException tE = new CertificateException(cause); - assertTrue(errNotExc, tE instanceof CertificateException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -153,7 +148,6 @@ */ public void testCertificateException05() { CertificateException tE = new CertificateException(tCause); - assertTrue(errNotExc, tE instanceof CertificateException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -177,7 +171,6 @@ */ public void testCertificateException06() { CertificateException tE = new CertificateException(null, null); - assertTrue(errNotExc, tE instanceof CertificateException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -196,8 +189,6 @@ CertificateException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -216,7 +207,6 @@ */ public void testCertificateException08() { CertificateException tE = new CertificateException(null, tCause); - assertTrue(errNotExc, tE instanceof CertificateException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -242,8 +232,6 @@ CertificateException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CertPathBuilder1Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertPathBuilder1Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertPathBuilder1Test.java (working copy) @@ -28,7 +28,7 @@ import java.security.Security; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; @@ -38,7 +38,7 @@ * */ -public class CertPathBuilder1Test extends PerformanceTest { +public class CertPathBuilder1Test extends TestCase { /** * Constructor for CertPathBuilderTests. Index: modules/security2/test/common/unit/java/security/cert/CertPathValidator2Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertPathValidator2Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertPathValidator2Test.java (working copy) @@ -28,7 +28,7 @@ import java.security.Security; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -36,7 +36,7 @@ * */ -public class CertPathValidator2Test extends PerformanceTest { +public class CertPathValidator2Test extends TestCase { private static final String defaultAlg = "CertPB"; public static final String CertPathValidatorProviderClass = "java.security.cert.MyCertPathValidatorSpi"; Index: modules/security2/test/common/unit/java/security/cert/PKIXBuilderParametersTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/PKIXBuilderParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/PKIXBuilderParametersTest.java (working copy) @@ -29,14 +29,14 @@ import java.util.Set; import org.apache.harmony.security.cert.TestUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PKIXBuilderParameters fields and methods * */ -public class PKIXBuilderParametersTest extends PerformanceTest { +public class PKIXBuilderParametersTest extends TestCase { private static final int DEFAULT_MAX_PATH_LEN = 5; /* * @see TestCase#setUp() @@ -70,8 +70,7 @@ throws InvalidAlgorithmParameterException { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } // both parameters are valid and non-null PKIXParameters p = @@ -90,8 +89,7 @@ throws InvalidAlgorithmParameterException { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } // both parameters are valid but CertSelector is null PKIXParameters p = new PKIXBuilderParameters(taSet, null); @@ -110,8 +108,7 @@ throws InvalidAlgorithmParameterException { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } HashSet originalSet = (HashSet)taSet; HashSet originalSetCopy = (HashSet)originalSet.clone(); @@ -132,19 +129,13 @@ * Assertion: NullPointerException - * if the specified Set is null */ - public final void testPKIXBuilderParametersSetCertSelector04() { - boolean npeHasBeenThrown = false; + public final void testPKIXBuilderParametersSetCertSelector04() throws Exception { try { // pass null - PKIXBuilderParameters pp = - new PKIXBuilderParameters((Set)null, null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXBuilderParameters((Set)null, null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -155,18 +146,12 @@ * (trustAnchors.isEmpty() == true) */ public final void testPKIXBuilderParametersSetCertSelector05() { - boolean iapeHasBeenThrown = false; try { // use empty set - PKIXBuilderParameters pp = - new PKIXBuilderParameters(new HashSet(), null); - } catch (Exception e) { - if (e instanceof InvalidAlgorithmParameterException) { - iapeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXBuilderParameters(new HashSet(), null); + fail("InvalidAlgorithmParameterException expected"); + } catch (InvalidAlgorithmParameterException e) { } - assertTrue(iapeHasBeenThrown); } /** @@ -176,24 +161,20 @@ * if any of the elements in the Set are not of type * java.security.cert.TrustAnchor */ - public final void testPKIXBuilderParametersSetCertSelector06() { + public final void testPKIXBuilderParametersSetCertSelector06() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + // add wrong object to valid set assertTrue(taSet.add(new Object())); - boolean cceHasBeenThrown = false; + try { - PKIXBuilderParameters pp = new PKIXBuilderParameters(taSet, null); - } catch (Exception e) { - if (e instanceof ClassCastException) { - cceHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXBuilderParameters(taSet, null); + fail("ClassCastException expected"); + } catch (ClassCastException e) { } - assertTrue(cceHasBeenThrown); } /** @@ -208,8 +189,7 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } // both parameters are valid and non-null PKIXParameters p = @@ -230,8 +210,7 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } // both parameters are valid but CertSelector is null PKIXParameters p = @@ -254,8 +233,7 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } // both parameters are valid but CertSelector is null PKIXParameters p = @@ -270,19 +248,13 @@ * Assertion: NullPointerException - * if the keystore is null */ - public final void testPKIXBuilderParametersKeyStoreCertSelector04() { - boolean npeHasBeenThrown = false; + public final void testPKIXBuilderParametersKeyStoreCertSelector04() throws Exception { try { // pass null - PKIXBuilderParameters pp = - new PKIXBuilderParameters((KeyStore)null, null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXBuilderParameters((KeyStore)null, null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -291,23 +263,18 @@ * Assertion: KeyStoreException - * if the keystore has not been initialized */ - public final void testPKIXBuilderParametersKeyStoreCertSelector05() { + public final void testPKIXBuilderParametersKeyStoreCertSelector05() throws Exception { KeyStore ks = TestUtils.getKeyStore(false, 0); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } - boolean kseHasBeenThrown = false; + try { // pass not initialized KeyStore - PKIXBuilderParameters pp = new PKIXBuilderParameters(ks, null); - } catch (Exception e) { - if (e instanceof KeyStoreException) { - kseHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXBuilderParameters(ks, null); + fail("KeyStoreException expected"); + } catch (KeyStoreException e) { } - assertTrue(kseHasBeenThrown); } /** @@ -317,23 +284,19 @@ * if the keystore does not contain at least one * trusted certificate entry */ - public final void testPKIXBuilderParametersKeyStoreCertSelector06() { + public final void testPKIXBuilderParametersKeyStoreCertSelector06() throws Exception { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); + fail(getName() + ": not performed (could not create test KeyStore)"); return; } - boolean iapeHasBeenThrown = false; + try { // pass KeyStore that does not contain trusted certificates - PKIXBuilderParameters pp = new PKIXBuilderParameters(ks, null); - } catch (Exception e) { - if (e instanceof InvalidAlgorithmParameterException) { - iapeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXBuilderParameters(ks, null); + fail("InvalidAlgorithmParameterException expected"); + } catch (InvalidAlgorithmParameterException e) { } - assertTrue(iapeHasBeenThrown); } /** @@ -347,8 +310,7 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null); assertEquals(DEFAULT_MAX_PATH_LEN, p.getMaxPathLength()); @@ -366,8 +328,7 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } // all these VALID maxPathLength values must be // set (and get) without exceptions @@ -391,21 +352,16 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } PKIXBuilderParameters p = new PKIXBuilderParameters(ks, null); - boolean ipeHasBeenThrown = false; + try { // pass parameter less than -1 p.setMaxPathLength(Integer.MIN_VALUE); - } catch (Exception e) { - if (e instanceof InvalidParameterException) { - ipeHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("InvalidParameterException expected"); + } catch (InvalidParameterException e) { } - assertTrue(ipeHasBeenThrown); } /** @@ -419,13 +375,12 @@ InvalidAlgorithmParameterException { KeyStore ks = TestUtils.getKeyStore(true,TestUtils.TRUSTED_AND_UNTRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } PKIXBuilderParameters p = new PKIXBuilderParameters(ks, new X509CertSelector()); String rep = p.toString(); - logln(getName() + ": " + rep); + assertNotNull(rep); } Index: modules/security2/test/common/unit/java/security/cert/CollectionCertStoreParametersTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CollectionCertStoreParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CollectionCertStoreParametersTest.java (working copy) @@ -25,14 +25,14 @@ import java.util.Vector; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for CollectionCertStoreParameters * */ -public class CollectionCertStoreParametersTest extends PerformanceTest { +public class CollectionCertStoreParametersTest extends TestCase { /* * @see TestCase#setUp() @@ -69,7 +69,6 @@ CertStoreParameters cp = new CollectionCertStoreParameters(); assertTrue("isCollectionCertStoreParameters", cp instanceof CollectionCertStoreParameters); - assertTrue("isCloneable", cp instanceof Cloneable); } /** @@ -81,16 +80,14 @@ CollectionCertStoreParameters cp = new CollectionCertStoreParameters(); Collection c = cp.getCollection(); assertTrue("isEmpty", c.isEmpty()); + // check that empty collection is immutable - boolean xHasBeenThrown = false; try { // try to modify it c.add(new Object()); + fail("empty collection must be immutable"); } catch (Exception e) { - xHasBeenThrown = true; - logln(getName() + ": " + e); } - assertTrue("isImmutable", xHasBeenThrown); } /** @@ -101,10 +98,7 @@ public final void testCollectionCertStoreParametersCollection01() { Vector certificates = new Vector(); certificates.add(new MyCertificate("TEST", new byte[] {})); - CollectionCertStoreParameters cp = - new CollectionCertStoreParameters(certificates); - assertTrue("isCertStoreParameters", cp instanceof CertStoreParameters); - assertTrue("isCloneable", cp instanceof Cloneable); + new CollectionCertStoreParameters(certificates); } /** @@ -120,8 +114,7 @@ // a Certificate or CRL Vector certificates = new Vector(); certificates.add(new String("Not a Certificate")); - CollectionCertStoreParameters cp = - new CollectionCertStoreParameters(certificates); + new CollectionCertStoreParameters(certificates); } /** @@ -156,17 +149,11 @@ * collection is null */ public final void testCollectionCertStoreParametersCollection04() { - boolean npeHasBeenThrown = false; try { - CollectionCertStoreParameters cp = - new CollectionCertStoreParameters(null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new CollectionCertStoreParameters(null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -225,7 +212,6 @@ CollectionCertStoreParameters cp = new CollectionCertStoreParameters(); String s = cp.toString(); - logln(getName() + ": " + s); assertTrue(s != null); } @@ -238,9 +224,8 @@ certificates.add(new MyCertificate("TEST", new byte[] {(byte)4})); CollectionCertStoreParameters cp = new CollectionCertStoreParameters(certificates); - String s = cp.toString(); - logln(getName() + ": " + s); - assertTrue(s != null); + + assertNotNull(cp.toString()); } /** Index: modules/security2/test/common/unit/java/security/cert/PKIXCertPathValidatorResultTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/PKIXCertPathValidatorResultTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/PKIXCertPathValidatorResultTest.java (working copy) @@ -26,14 +26,14 @@ import java.security.spec.InvalidKeySpecException; import org.apache.harmony.security.cert.TestUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PKIXCertPathValidatorResult * */ -public class PKIXCertPathValidatorResultTest extends PerformanceTest { +public class PKIXCertPathValidatorResultTest extends TestCase { /** * PublicKey stub */ @@ -89,14 +89,12 @@ NoSuchAlgorithmException { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } - PKIXCertPathValidatorResult vr = - new PKIXCertPathValidatorResult( - ta, - TestUtils.getPolicyTree(), - testPublicKey); + new PKIXCertPathValidatorResult( + ta, + TestUtils.getPolicyTree(), + testPublicKey); } /** @@ -106,21 +104,15 @@ * TrustAnchor parameter is null */ public final void testPKIXCertPathValidatorResult02() { - boolean npeHasBeenThrown = false; try { // pass null - PKIXCertPathValidatorResult vr = - new PKIXCertPathValidatorResult( - null, - TestUtils.getPolicyTree(), - testPublicKey); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXCertPathValidatorResult( + null, + TestUtils.getPolicyTree(), + testPublicKey); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -132,24 +124,17 @@ public final void testPKIXCertPathValidatorResult03() { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } - boolean npeHasBeenThrown = false; try { // pass null - PKIXCertPathValidatorResult vr = - new PKIXCertPathValidatorResult( - ta, - TestUtils.getPolicyTree(), - null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXCertPathValidatorResult( + ta, + TestUtils.getPolicyTree(), + null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -157,19 +142,16 @@ * PolicyNode, PublicKey) constructor
* Assertion: PolicyNodecan be null */ - public final void testPKIXCertPathValidatorResult04() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testPKIXCertPathValidatorResult04() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } - PKIXCertPathValidatorResult vr = - new PKIXCertPathValidatorResult( - ta, - null, - testPublicKey); + + new PKIXCertPathValidatorResult( + ta, + null, + testPublicKey); } /** @@ -178,19 +160,18 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testGetTrustAnchor() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testGetTrustAnchor() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult( ta, null, testPublicKey); + // must return the same reference passed // as a parameter to the constructor assertSame(ta, vr.getTrustAnchor()); @@ -202,20 +183,19 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testGetPublicKey() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testGetPublicKey() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + PublicKey pk = testPublicKey; PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult( ta, null, pk); + // must return the same reference passed // as a parameter to the constructor assertSame(pk, vr.getPublicKey()); @@ -229,14 +209,12 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testGetPolicyTree01() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testGetPolicyTree01() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + // valid policy tree case; PolicyNode pn = TestUtils.getPolicyTree(); PKIXCertPathValidatorResult vr = @@ -244,6 +222,7 @@ ta, pn, testPublicKey); + // must return the same reference passed // as a parameter to the constructor assertSame(pn, vr.getPolicyTree()); @@ -257,20 +236,19 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testGetPolicyTree02() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testGetPolicyTree02() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + // no valid policy tree case (null) PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult( ta, null, testPublicKey); + // must return the same reference passed // as a parameter to the constructor assertNull(vr.getPolicyTree()); @@ -282,21 +260,21 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testClone() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testClone() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + PKIXCertPathValidatorResult vr1 = new PKIXCertPathValidatorResult( ta, TestUtils.getPolicyTree(), testPublicKey); + PKIXCertPathValidatorResult vr2 = (PKIXCertPathValidatorResult) vr1.clone(); + // check that method makes shallow copy assertNotSame("notSame", vr1, vr2); assertSame("trustAncor", vr1.getTrustAnchor(), vr2.getTrustAnchor()); @@ -310,22 +288,19 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testToString01() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testToString01() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult( ta, TestUtils.getPolicyTree(), testPublicKey); - String rep = vr.toString(); - logln(getName() + ": " + rep); - assertNotNull(rep); + + assertNotNull(vr.toString()); } /** @@ -334,22 +309,19 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testToString02() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testToString02() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + PKIXCertPathValidatorResult vr = new PKIXCertPathValidatorResult( ta, null, testPublicKey); - String rep = vr.toString(); - logln(getName() + ": " + rep); - assertNotNull(rep); + + assertNotNull(vr.toString()); } } Index: modules/security2/test/common/unit/java/security/cert/PKIXCertPathBuilderResultTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/PKIXCertPathBuilderResultTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/PKIXCertPathBuilderResultTest.java (working copy) @@ -27,14 +27,14 @@ import org.apache.harmony.security.cert.MyCertPath; import org.apache.harmony.security.cert.TestUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PKIXCertPathBuilderResult * */ -public class PKIXCertPathBuilderResultTest extends PerformanceTest { +public class PKIXCertPathBuilderResultTest extends TestCase { /** * Cert path encoding stub */ @@ -95,8 +95,7 @@ NoSuchAlgorithmException { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } CertPathBuilderResult r = new PKIXCertPathBuilderResult( @@ -119,8 +118,7 @@ NoSuchAlgorithmException { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } CertPathBuilderResult r = new PKIXCertPathBuilderResult( @@ -140,25 +138,19 @@ public final void testPKIXCertPathBuilderResult03() { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } - boolean npeHasBeenThrown = false; + try { // pass null - CertPathBuilderResult r = - new PKIXCertPathBuilderResult( - null, - ta, - TestUtils.getPolicyTree(), - testPublicKey); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXCertPathBuilderResult( + null, + ta, + TestUtils.getPolicyTree(), + testPublicKey); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -170,15 +162,13 @@ public final void testPKIXCertPathBuilderResult04() { try { // pass null - CertPathBuilderResult r = - new PKIXCertPathBuilderResult( - new MyCertPath(testEncoding), - null, - TestUtils.getPolicyTree(), - testPublicKey); - fail(getName() + "NullPointerException has not been thrown"); - } catch (NullPointerException ok) { - logln(getName() + ": " + ok); + new PKIXCertPathBuilderResult( + new MyCertPath(testEncoding), + null, + TestUtils.getPolicyTree(), + testPublicKey); + fail("NPE expected"); + } catch (NullPointerException e) { } } @@ -191,25 +181,19 @@ public final void testPKIXCertPathBuilderResult05() { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } - boolean npeHasBeenThrown = false; + try { // pass null - CertPathBuilderResult r = - new PKIXCertPathBuilderResult( - new MyCertPath(testEncoding), - ta, - TestUtils.getPolicyTree(), - null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXCertPathBuilderResult( + new MyCertPath(testEncoding), + ta, + TestUtils.getPolicyTree(), + null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -219,14 +203,12 @@ * @throws NoSuchAlgorithmException * @throws InvalidKeySpecException */ - public final void testGetCertPath() - throws InvalidKeySpecException, - NoSuchAlgorithmException { + public final void testGetCertPath() throws Exception { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } + CertPath cp = new MyCertPath(testEncoding); CertPathBuilderResult r = new PKIXCertPathBuilderResult( @@ -234,6 +216,7 @@ ta, TestUtils.getPolicyTree(), testPublicKey); + // must return the same reference // as passed to the constructor assertSame(cp, r.getCertPath()); @@ -250,8 +233,7 @@ NoSuchAlgorithmException { TrustAnchor ta = TestUtils.getTrustAnchor(); if (ta == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor)"); } CertPathBuilderResult r = new PKIXCertPathBuilderResult( @@ -259,9 +241,8 @@ ta, TestUtils.getPolicyTree(), testPublicKey); - String rep = r.toString(); - logln(getName() + ": " + rep); - assertNotNull(rep); + + assertNotNull(r.toString()); } } Index: modules/security2/test/common/unit/java/security/cert/CRLTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CRLTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CRLTest.java (working copy) @@ -22,14 +22,14 @@ package java.security.cert; import org.apache.harmony.security.cert.MyCRL; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for java.security.cert.CRL fields and methods * */ -public class CRLTest extends PerformanceTest { +public class CRLTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/cert/CertificateTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateTest.java (working copy) @@ -27,14 +27,14 @@ import java.security.SignatureException; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for Certificate fields and methods * */ -public class CertificateTest extends PerformanceTest { +public class CertificateTest extends TestCase { /** * Meaningless cert encoding just for testing purposes */ @@ -75,7 +75,7 @@ public final void testHashCode() { Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding); Certificate c2 = new MyCertificate("TEST_TYPE", testEncoding); - logln(getName() + ": " + c1.hashCode()); + assertTrue(c1.hashCode() == c2.hashCode()); } @@ -86,7 +86,7 @@ public final void testHashCodeEqualsObject() { Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding); Certificate c2 = new MyCertificate("TEST_TYPE", testEncoding); - logln(getName() + ": " + c1.hashCode()); + assertTrue((c1.hashCode() == c2.hashCode()) && c1.equals(c2)); } Index: modules/security2/test/common/unit/java/security/cert/CertStoreExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertStoreExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertStoreExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.cert.CertStoreException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for CertStoreException class constructors and methods. * */ -public class CertStoreExceptionTest extends PerformanceTest { +public class CertStoreExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertStoreException01() { CertStoreException tE = new CertStoreException(); - assertTrue(errNotExc, tE instanceof CertStoreException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertStoreException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertStoreException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertStoreException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testCertStoreException03() { String msg = null; CertStoreException tE = new CertStoreException(msg); - assertTrue(errNotExc, tE instanceof CertStoreException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -135,7 +131,6 @@ public void testCertStoreException04() { Throwable cause = null; CertStoreException tE = new CertStoreException(cause); - assertTrue(errNotExc, tE instanceof CertStoreException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -152,7 +147,6 @@ */ public void testCertStoreException05() { CertStoreException tE = new CertStoreException(tCause); - assertTrue(errNotExc, tE instanceof CertStoreException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -176,7 +170,6 @@ */ public void testCertStoreException06() { CertStoreException tE = new CertStoreException(null, null); - assertTrue(errNotExc, tE instanceof CertStoreException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -195,8 +188,6 @@ CertStoreException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertStoreException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertStoreException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -215,7 +206,6 @@ */ public void testCertStoreException08() { CertStoreException tE = new CertStoreException(null, tCause); - assertTrue(errNotExc, tE instanceof CertStoreException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -241,8 +231,6 @@ CertStoreException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertStoreException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertStoreException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CertificateFactory1Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateFactory1Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateFactory1Test.java (working copy) @@ -36,7 +36,7 @@ import org.apache.harmony.security.SpiEngUtils; import org.apache.harmony.security.cert.MyCertPath; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -44,7 +44,7 @@ * */ -public class CertificateFactory1Test extends PerformanceTest { +public class CertificateFactory1Test extends TestCase { /** * Constructor for CertificateFactoryTests. @@ -114,8 +114,6 @@ for (int i = 0; i < validValues.length; i++) { CertificateFactory certF = CertificateFactory .getInstance(validValues[i]); - assertTrue("Not CertificateFactory object", - certF instanceof CertificateFactory); assertEquals("Incorrect type: ", validValues[i], certF.getType()); } } @@ -213,8 +211,6 @@ for (int i = 0; i < validValues.length; i++) { certF = CertificateFactory.getInstance(validValues[i], defaultProviderName); - assertTrue("Not CertificateFactory object", - certF instanceof CertificateFactory); assertEquals("Incorrect type", certF.getType(), validValues[i]); assertEquals("Incorrect provider name", certF.getProvider() .getName(), defaultProviderName); @@ -286,8 +282,6 @@ for (int i = 0; i < validValues.length; i++) { certF = CertificateFactory.getInstance(validValues[i], defaultProvider); - assertTrue("Not CertificateFactory object", - certF instanceof CertificateFactory); assertEquals("Incorrect provider", certF.getProvider(), defaultProvider); assertEquals("Incorrect type", certF.getType(), validValues[i]); @@ -314,7 +308,7 @@ String s1 = (String) it1.next(); boolean yesNo = false; while (it2.hasNext()) { - if (s1.equals((String) it2.next())) { + if (s1.equals(it2.next())) { yesNo = true; break; } @@ -330,7 +324,7 @@ String s1 = (String) it1.next(); boolean yesNo = false; while (it2.hasNext()) { - if (s1.equals((String) it2.next())) { + if (s1.equals(it2.next())) { yesNo = true; break; } @@ -358,10 +352,8 @@ CertificateFactory[] certFs = initCertFs(); assertNotNull("CertificateFactory objects were not created", certFs); byte [] bb = {}; - InputStream is = (InputStream) new ByteArrayInputStream(bb); - Certificate cer; + InputStream is = new ByteArrayInputStream(bb); Collection colCer; - CRL crl; Collection colCrl; for (int i = 0; i < certFs.length; i++) { try { @@ -370,20 +362,19 @@ } catch (CertificateException e) { } catch (NullPointerException e) { } - is = (InputStream) new ByteArrayInputStream(bb); + is = new ByteArrayInputStream(bb); try { certFs[i].generateCertificates(null); fail("generateCertificates must throw CertificateException or NullPointerException when input stream is null"); } catch (CertificateException e) { } catch (NullPointerException e) { } - is = (InputStream) new ByteArrayInputStream(bb); + is = new ByteArrayInputStream(bb); try { - cer = certFs[i].generateCertificate(is); - logln("generateCertificate(..) returns certificate: " + cer); + certFs[i].generateCertificate(is); } catch (CertificateException e) { } - is = (InputStream) new ByteArrayInputStream(bb); + is = new ByteArrayInputStream(bb); try { colCer = certFs[i].generateCertificates(is); if (colCer != null) { @@ -394,8 +385,7 @@ } for (int i = 0; i < certFs.length; i++) { try { - crl = certFs[i].generateCRL(null); - logln("generateCRL(..) returns from null stream CRL: " + crl); + certFs[i].generateCRL(null); } catch (CRLException e) { } catch (NullPointerException e) { } @@ -407,13 +397,12 @@ } catch (CRLException e) { } catch (NullPointerException e) { } - is = (InputStream) new ByteArrayInputStream(bb); + is = new ByteArrayInputStream(bb); try { - crl = certFs[i].generateCRL(is); - logln("generateCRL(..) returns from empty stream CRL: " + crl); + certFs[i].generateCRL(is); } catch (CRLException e) { } - is = (InputStream) new ByteArrayInputStream(bb); + is = new ByteArrayInputStream(bb); try { certFs[i].generateCRLs(is); colCrl = certFs[i].generateCRLs(null); @@ -504,8 +493,7 @@ CertificateFactory[] certFs = initCertFs(); assertNotNull("CertificateFactory objects were not created", certFs); InputStream is1 = null; - InputStream is2 = (InputStream) new ByteArrayInputStream(new byte[10]); - String provider = null; + InputStream is2 = new ByteArrayInputStream(new byte[10]); for (int i = 0; i < certFs.length; i++) { try { @@ -595,7 +583,6 @@ CertificateFactory[] certFs = initCertFs(); assertNotNull("CertificateFactory objects were not created", certFs); List list = null; - String provider = null; for (int i = 0; i < certFs.length; i++) { try { certFs[i].generateCertPath(list); @@ -619,7 +606,7 @@ } CertificateFactory[] certFs = initCertFs(); assertNotNull("CertificateFactory objects were not created", certFs); - List list = (List) new Vector(); + List list = new Vector(); for (int i = 0; i < certFs.length; i++) { CertPath cp = certFs[i].generateCertPath(list); List list1 = cp.getCertificates(); @@ -641,7 +628,7 @@ CertificateFactory[] certFs = initCertFs(); assertNotNull("CertificateFactory objects were not created", certFs); MyCertificate ms = createMC(); - List list = (List) new Vector(); + List list = new Vector(); list.add(ms); for (int i = 0; i < certFs.length; i++) { try { @@ -665,7 +652,6 @@ CertificateFactorySpi spi = new MyCertificateFactorySpi(); CertificateFactory cf = new myCertificateFactory(spi, defaultProvider, defaultType); - assertTrue("Not CertificateFactory object", cf instanceof CertificateFactory); assertEquals("Incorrect type", cf.getType(), defaultType); assertEquals("Incorrect provider", cf.getProvider(), defaultProvider); try { Index: modules/security2/test/common/unit/java/security/cert/CertStore1Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertStore1Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertStore1Test.java (working copy) @@ -29,7 +29,7 @@ import java.util.Collection; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; @@ -39,7 +39,7 @@ * */ -public class CertStore1Test extends PerformanceTest { +public class CertStore1Test extends TestCase { /** * Constructor for CertStoreTests. Index: modules/security2/test/common/unit/java/security/cert/CertificateFactory3Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateFactory3Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateFactory3Test.java (working copy) @@ -33,7 +33,7 @@ import java.util.Vector; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.test.TestUtils; @@ -41,7 +41,7 @@ * Tests for CertificateFactory class methods */ -public class CertificateFactory3Test extends PerformanceTest { +public class CertificateFactory3Test extends TestCase { /** * Constructor for CertificateFactoryFileTests. @@ -58,10 +58,6 @@ private static String defaultType = CertificateFactory1Test.defaultType; - private final static String[] validValues = CertificateFactory1Test.validValues; - - private final static String[] invalidValues = SpiEngUtils.invalidValues; - public static String fileCertificateX509 = "java/security/cert/serialization/Certificate.X.509"; public static String fileCertPathPki = "java/security/cert/serialization/CertPath.PkiPath"; @@ -169,7 +165,7 @@ FileInputStream fis = new FileInputStream(fileCertificateX509); Certificate cert = certFs[0].generateCertificate(fis); fis.close(); - List list = (List) new Vector(); + List list = new Vector(); list.add(cert); for (int i = 0; i < certFs.length; i++) { CertPath certPath = null; @@ -223,7 +219,7 @@ for (int i = 0; i < certFs.length; i++) { Iterator it = certFs[0].getCertPathEncodings(); if (it.hasNext()) { - if (certPathEncoding.equals((String)it.next())) { + if (certPathEncoding.equals(it.next())) { CertPath certPath = null; FileInputStream fis = new FileInputStream(fileCertPathPki); certPath = certFs[i].generateCertPath(fis); @@ -232,7 +228,7 @@ List list1 = certPath.getCertificates(); assertFalse("Result list is empty",list1.isEmpty()); } else { - logln("Default encoding is not ".concat(fileCertPathPki)); + fail("Default encoding is not ".concat(certPathEncoding)); } } else { fail("There are no CertPath encodings"); Index: modules/security2/test/common/unit/java/security/cert/LDAPCertStoreParametersTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/LDAPCertStoreParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/LDAPCertStoreParametersTest.java (working copy) @@ -21,14 +21,14 @@ package java.security.cert; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for java.security.cert.LDAPCertStoreParameters * fields and methods * */ -public class LDAPCertStoreParametersTest extends PerformanceTest { +public class LDAPCertStoreParametersTest extends TestCase { /* * @see TestCase#setUp() @@ -65,7 +65,6 @@ CertStoreParameters cp = new LDAPCertStoreParameters(); assertTrue("isLDAPCertStoreParameters", cp instanceof LDAPCertStoreParameters); - assertTrue("isCloneable", cp instanceof Cloneable); } /** @@ -88,7 +87,6 @@ CertStoreParameters cp = new LDAPCertStoreParameters("myhost"); assertTrue("isLDAPCertStoreParameters", cp instanceof LDAPCertStoreParameters); - assertTrue("isCloneable", cp instanceof Cloneable); } /** @@ -109,16 +107,11 @@ * if serverName is null */ public final void testLDAPCertStoreParametersString03() { - boolean npeHasBeenThrown = false; try { - LDAPCertStoreParameters cp = new LDAPCertStoreParameters(null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new LDAPCertStoreParameters(null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -130,7 +123,6 @@ CertStoreParameters cp = new LDAPCertStoreParameters("myhost", 1098); assertTrue("isLDAPCertStoreParameters", cp instanceof LDAPCertStoreParameters); - assertTrue("isCloneable", cp instanceof Cloneable); } /** @@ -153,16 +145,11 @@ * if serverName is null */ public final void testLDAPCertStoreParametersStringint03() { - boolean npeHasBeenThrown = false; try { - LDAPCertStoreParameters cp = new LDAPCertStoreParameters(null, 0); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new LDAPCertStoreParameters(null, 0); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -187,9 +174,8 @@ public final void testToString() { LDAPCertStoreParameters cp1 = new LDAPCertStoreParameters("myhost", 1101); - String rep = cp1.toString(); - logln(getName() + ": " + rep); - assertTrue(rep != null); + + assertNotNull(cp1.toString()); } /** Index: modules/security2/test/common/unit/java/security/cert/CertPathValidatorExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertPathValidatorExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertPathValidatorExceptionTest.java (working copy) @@ -24,7 +24,7 @@ import java.security.cert.CertPathValidatorException; import java.security.cert.CertPath; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -32,7 +32,7 @@ * methods. * */ -public class CertPathValidatorExceptionTest extends PerformanceTest { +public class CertPathValidatorExceptionTest extends TestCase { public static void main(String[] args) { } @@ -80,7 +80,6 @@ */ public void testCertPathValidatorException01() { CertPathValidatorException tE = new CertPathValidatorException(); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -99,8 +98,6 @@ CertPathValidatorException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertPathValidatorException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertPathValidatorException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -120,7 +117,6 @@ public void testCertPathValidatorException03() { String msg = null; CertPathValidatorException tE = new CertPathValidatorException(msg); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -138,7 +134,6 @@ public void testCertPathValidatorException04() { Throwable cause = null; CertPathValidatorException tE = new CertPathValidatorException(cause); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -155,7 +150,6 @@ */ public void testCertPathValidatorException05() { CertPathValidatorException tE = new CertPathValidatorException(tCause); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -180,7 +174,6 @@ public void testCertPathValidatorException06() { CertPathValidatorException tE = new CertPathValidatorException(null, null); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -199,8 +192,6 @@ CertPathValidatorException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertPathValidatorException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertPathValidatorException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -220,7 +211,6 @@ public void testCertPathValidatorException08() { CertPathValidatorException tE = new CertPathValidatorException(null, tCause); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -246,8 +236,6 @@ CertPathValidatorException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertPathValidatorException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertPathValidatorException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { @@ -280,7 +268,6 @@ public void testCertPathValidatorException10() { CertPathValidatorException tE = new CertPathValidatorException(null, null, null, -1); - assertTrue(errNotExc, tE instanceof CertPathValidatorException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); assertNull("getCertPath() must return null", tE.getCertPath()); @@ -301,13 +288,11 @@ * IllegalArgumentException */ public void testCertPathValidatorException11() { - CertPathValidatorException tE; int[] indx = { 0, 1, 100, Integer.MAX_VALUE, Integer.MIN_VALUE }; for (int j = 0; j < indx.length; j++) { for (int i = 0; i < msgs.length; i++) { try { - tE = new CertPathValidatorException(msgs[i], tCause, null, - indx[j]); + new CertPathValidatorException(msgs[i], tCause, null, indx[j]); fail("Error. IllegalArgumentException was not thrown as expected. " + " msg: " + msgs[i] @@ -331,8 +316,6 @@ for (int i = 0; i < msgs.length; i++) { try { tE = new CertPathValidatorException(msgs[i], tCause, null, -1); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat( - ")"), tE instanceof CertPathValidatorException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { @@ -370,7 +353,6 @@ * certPath.getCertificates().size() throws: IndexOutOfBoundsException */ public void testCertPathValidatorException13() { - CertPathValidatorException tE; myCertPath mcp = new myCertPath("X.509", ""); CertPath cp = mcp.get("X.509"); int[] indx = { -2, -100, 0, 1, 100, Integer.MAX_VALUE, @@ -378,8 +360,7 @@ for (int j = 0; j < indx.length; j++) { for (int i = 0; i < msgs.length; i++) { try { - tE = new CertPathValidatorException(msgs[i], tCause, cp, - indx[j]); + new CertPathValidatorException(msgs[i], tCause, cp, indx[j]); fail("IndexOutOfBoundsException was not thrown as expected. " + " msg: " + msgs[i] @@ -405,8 +386,6 @@ for (int i = 0; i < msgs.length; i++) { try { tE = new CertPathValidatorException(msgs[i], tCause, cp, -1); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat( - ")"), tE instanceof CertPathValidatorException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/PKIXParametersTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/PKIXParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/PKIXParametersTest.java (working copy) @@ -33,14 +33,14 @@ import java.util.Set; import org.apache.harmony.security.cert.TestUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PKIXParameters fields and methods * */ -public class PKIXParametersTest extends PerformanceTest { +public class PKIXParametersTest extends TestCase { /** * Some valid issuer name */ @@ -84,8 +84,7 @@ throws InvalidAlgorithmParameterException { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } // use valid parameter CertPathParameters cpp = new PKIXParameters(taSet); @@ -102,8 +101,7 @@ throws InvalidAlgorithmParameterException { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } HashSet originalSet = (HashSet)taSet; HashSet originalSetCopy = (HashSet)originalSet.clone(); @@ -122,18 +120,13 @@ * Assertion: NullPointerException - * if the specified Set is null */ - public final void testPKIXParametersSet03() { - boolean npeHasBeenThrown = false; + public final void testPKIXParametersSet03() throws Exception { try { // pass null - PKIXParameters pp = new PKIXParameters((Set)null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXParameters((Set)null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -143,17 +136,12 @@ * (trustAnchors.isEmpty() == true) */ public final void testPKIXParametersSet04() { - boolean iapeHasBeenThrown = false; try { // use empty set - PKIXParameters pp = new PKIXParameters(new HashSet()); - } catch (Exception e) { - if (e instanceof InvalidAlgorithmParameterException) { - iapeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXParameters(new HashSet()); + fail("InvalidAlgorithmParameterException expected"); + } catch (InvalidAlgorithmParameterException e) { } - assertTrue(iapeHasBeenThrown); } /** @@ -162,24 +150,19 @@ * if any of the elements in the Set are not of type * java.security.cert.TrustAnchor */ - public final void testPKIXParametersSet05() { + public final void testPKIXParametersSet05() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + // add wrong object to valid set assertTrue(taSet.add(new Object())); - boolean cceHasBeenThrown = false; try { - PKIXParameters pp = new PKIXParameters(taSet); - } catch (Exception e) { - if (e instanceof ClassCastException) { - cceHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXParameters(taSet); + fail("ClassCastException expected"); + } catch (ClassCastException e) { } - assertTrue(cceHasBeenThrown); } /** @@ -190,14 +173,12 @@ * @throws InvalidAlgorithmParameterException * @throws KeyStoreException */ - public final void testPKIXParametersKeyStore01() - throws KeyStoreException, - InvalidAlgorithmParameterException { + public final void testPKIXParametersKeyStore01() throws Exception { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + // use valid parameter - KeyStore containing // only trusted X.509 certificates CertPathParameters cpp = new PKIXParameters(ks); @@ -212,18 +193,15 @@ * @throws InvalidAlgorithmParameterException * @throws KeyStoreException */ - public final void testPKIXParametersKeyStore02() - throws KeyStoreException, - InvalidAlgorithmParameterException { + public final void testPKIXParametersKeyStore02() throws Exception { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED_AND_UNTRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + // use valid parameter - KeyStore containing // both trusted and untrusted X.509 certificates PKIXParameters cpp = new PKIXParameters(ks); - assertTrue("instanceof", cpp instanceof PKIXParameters); assertEquals("size", 1, cpp.getTrustAnchors().size()); } @@ -234,18 +212,13 @@ * @throws InvalidAlgorithmParameterException * @throws KeyStoreException */ - public final void testPKIXParametersKeyStore03() { - boolean npeHasBeenThrown = false; + public final void testPKIXParametersKeyStore03() throws Exception { try { // pass null - PKIXParameters pp = new PKIXParameters((KeyStore)null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXParameters((KeyStore)null); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -253,23 +226,18 @@ * Assertion: KeyStoreException - * if the keystore has not been initialized */ - public final void testPKIXParametersKeyStore04() { + public final void testPKIXParametersKeyStore04() throws Exception { KeyStore ks = TestUtils.getKeyStore(false, 0); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } - boolean kseHasBeenThrown = false; + try { // pass not initialized KeyStore - PKIXParameters pp = new PKIXParameters(ks); - } catch (Exception e) { - if (e instanceof KeyStoreException) { - kseHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXParameters(ks); + fail("KeyStoreException expected"); + } catch (KeyStoreException e) { } - assertTrue(kseHasBeenThrown); } /** @@ -278,23 +246,18 @@ * if the keystore does not contain at least one * trusted certificate entry */ - public final void testPKIXParametersKeyStore05() { + public final void testPKIXParametersKeyStore05() throws Exception { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.UNTRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } - boolean iapeHasBeenThrown = false; + try { // pass KeyStore that does not contain trusted certificates - PKIXParameters pp = new PKIXParameters(ks); - } catch (Exception e) { - if (e instanceof InvalidAlgorithmParameterException) { - iapeHasBeenThrown = true; - } - logln(getName() + ": " + e); + new PKIXParameters(ks); + fail("InvalidAlgorithmParameterException expected"); + } catch (InvalidAlgorithmParameterException e) { } - assertTrue(iapeHasBeenThrown); } /** @@ -304,13 +267,12 @@ * Assertion: returns the current value of the PolicyQualifiersRejected flag * @throws InvalidAlgorithmParameterException */ - public final void testGetPolicyQualifiersRejected() - throws InvalidAlgorithmParameterException { + public final void testGetPolicyQualifiersRejected() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertTrue(p.getPolicyQualifiersRejected()); } @@ -321,13 +283,12 @@ * PolicyQualifiersRejected flag * @throws InvalidAlgorithmParameterException */ - public final void testSetPolicyQualifiersRejected() - throws InvalidAlgorithmParameterException { + public final void testSetPolicyQualifiersRejected() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setPolicyQualifiersRejected(false); assertFalse("setFalse",p.getPolicyQualifiersRejected()); @@ -343,13 +304,12 @@ * (isAnyPolicyInhibited() returns false). * @throws InvalidAlgorithmParameterException */ - public final void testIsAnyPolicyInhibited() - throws InvalidAlgorithmParameterException { + public final void testIsAnyPolicyInhibited() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertFalse(p.isAnyPolicyInhibited()); } @@ -360,13 +320,12 @@ * should be processed if it is included in a certificate * @throws InvalidAlgorithmParameterException */ - public final void testSetAnyPolicyInhibited() - throws InvalidAlgorithmParameterException { + public final void testSetAnyPolicyInhibited() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setAnyPolicyInhibited(true); assertTrue("setTrue", p.isAnyPolicyInhibited()); @@ -381,13 +340,12 @@ * Assertion: by default, the ExplicitPolicyRequired flag is false * @throws InvalidAlgorithmParameterException */ - public final void testIsExplicitPolicyRequired() - throws InvalidAlgorithmParameterException { + public final void testIsExplicitPolicyRequired() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertFalse(p.isExplicitPolicyRequired()); } @@ -397,13 +355,12 @@ * Assertion: sets the ExplicitPolicyRequired flag * @throws InvalidAlgorithmParameterException */ - public final void testSetExplicitPolicyRequired() - throws InvalidAlgorithmParameterException { + public final void testSetExplicitPolicyRequired() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setExplicitPolicyRequired(true); assertTrue("setTrue", p.isExplicitPolicyRequired()); @@ -417,13 +374,12 @@ * Assertion: by default, policy mapping is not inhibited (the flag is false) * @throws InvalidAlgorithmParameterException */ - public final void testIsPolicyMappingInhibited() - throws InvalidAlgorithmParameterException { + public final void testIsPolicyMappingInhibited() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertFalse(p.isPolicyMappingInhibited()); } @@ -433,13 +389,12 @@ * Assertion: sets the PolicyMappingInhibited flag * @throws InvalidAlgorithmParameterException */ - public final void testSetPolicyMappingInhibited() - throws InvalidAlgorithmParameterException { + public final void testSetPolicyMappingInhibited() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setPolicyMappingInhibited(true); assertTrue("setTrue", p.isPolicyMappingInhibited()); @@ -454,13 +409,12 @@ * this flag is set to true * @throws InvalidAlgorithmParameterException */ - public final void testIsRevocationEnabled() - throws InvalidAlgorithmParameterException { + public final void testIsRevocationEnabled() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertTrue(p.isRevocationEnabled()); } @@ -470,13 +424,12 @@ * Assertion: sets the RevocationEnabled flag * @throws InvalidAlgorithmParameterException */ - public final void testSetRevocationEnabled() - throws InvalidAlgorithmParameterException { + public final void testSetRevocationEnabled() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setRevocationEnabled(false); assertFalse("setFalse", p.isRevocationEnabled()); @@ -490,13 +443,12 @@ * or null if not set * @throws InvalidAlgorithmParameterException */ - public final void testGetSigProvider() - throws InvalidAlgorithmParameterException { + public final void testGetSigProvider() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertNull("not set", p.getSigProvider()); p.setSigProvider("Some Provider"); @@ -507,13 +459,12 @@ * Test for setSigProvider(String) method
* Assertion: sets the signature provider's name */ - public final void testSetSigProvider() - throws InvalidAlgorithmParameterException { + public final void testSetSigProvider() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); String sigProviderName = "Some Provider"; p.setSigProvider(sigProviderName); @@ -528,13 +479,12 @@ * the constraints on the target certificate (or null) * @throws InvalidAlgorithmParameterException */ - public final void testGetTargetCertConstraints01() - throws InvalidAlgorithmParameterException { + public final void testGetTargetCertConstraints01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertNull(p.getTargetCertConstraints()); } @@ -546,14 +496,12 @@ * @throws InvalidAlgorithmParameterException * @throws IOException */ - public final void testGetTargetCertConstraints02() - throws InvalidAlgorithmParameterException, - IOException { + public final void testGetTargetCertConstraints02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + X509CertSelector x509cs = new X509CertSelector(); PKIXParameters p = new PKIXParameters(taSet); p.setTargetCertConstraints(x509cs); @@ -578,14 +526,12 @@ * @throws IOException * @throws InvalidAlgorithmParameterException */ - public final void testSetTargetCertConstraints01() - throws IOException, - InvalidAlgorithmParameterException { + public final void testSetTargetCertConstraints01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + X509CertSelector x509cs = new X509CertSelector(); x509cs.setIssuer(testIssuer); PKIXParameters p = new PKIXParameters(taSet); @@ -604,14 +550,12 @@ * @throws IOException * @throws InvalidAlgorithmParameterException */ - public final void testSetTargetCertConstraints02() - throws IOException, - InvalidAlgorithmParameterException { + public final void testSetTargetCertConstraints02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + X509CertSelector x509cs = new X509CertSelector(); PKIXParameters p = new PKIXParameters(taSet); p.setTargetCertConstraints(x509cs); @@ -629,13 +573,12 @@ * Assertion: list ... (may be empty, but never null) * @throws InvalidAlgorithmParameterException */ - public final void testGetCertStores01() - throws InvalidAlgorithmParameterException { + public final void testGetCertStores01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertNotNull("notNull", p.getCertStores()); assertTrue("isEmpty", p.getCertStores().isEmpty()); @@ -647,24 +590,21 @@ * of CertStores * @throws InvalidAlgorithmParameterException */ - public final void testGetCertStores02() - throws InvalidAlgorithmParameterException { + public final void testGetCertStores02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); List cs = p.getCertStores(); - boolean modificationFailed = false; + try { // try to modify returned list cs.add(new Object()); + fail("must be immutable"); } catch (Exception e) { - modificationFailed = true; - logln(getName() + ": " + e); } - assertTrue(modificationFailed); } /** @@ -673,14 +613,12 @@ * @throws NoSuchAlgorithmException * @throws InvalidAlgorithmParameterException */ - public final void testSetCertStores01() - throws InvalidAlgorithmParameterException, - NoSuchAlgorithmException { + public final void testSetCertStores01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setCertStores(TestUtils.getCollectionCertStoresList()); // check that list has been set @@ -692,13 +630,12 @@ * Assertion: list ... may be null * @throws InvalidAlgorithmParameterException */ - public final void testSetCertStores02() - throws InvalidAlgorithmParameterException { + public final void testSetCertStores02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); // add null p.setCertStores(null); @@ -717,14 +654,12 @@ * @throws NoSuchAlgorithmException * @throws InvalidAlgorithmParameterException */ - public final void testSetCertStores03() - throws InvalidAlgorithmParameterException, - NoSuchAlgorithmException { + public final void testSetCertStores03() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); List l = TestUtils.getCollectionCertStoresList(); p.setCertStores(l); @@ -743,28 +678,22 @@ * @throws InvalidAlgorithmParameterException * @throws NoSuchAlgorithmException */ - public final void testSetCertStores04() - throws InvalidAlgorithmParameterException, - NoSuchAlgorithmException { + public final void testSetCertStores04() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); List l = TestUtils.getCollectionCertStoresList(); // add wrong object to valid set assertTrue(l.add(new Object())); - boolean cceHasBeenThrown = false; + try { p.setCertStores(l); - } catch (Exception e) { - if (e instanceof ClassCastException) { - cceHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("ClassCastException expected"); + } catch (ClassCastException e) { } - assertTrue(cceHasBeenThrown); } /** @@ -774,14 +703,12 @@ * @throws InvalidAlgorithmParameterException * @throws NoSuchAlgorithmException */ - public final void testAddCertStore01() - throws InvalidAlgorithmParameterException, - NoSuchAlgorithmException { + public final void testAddCertStore01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.addCertStore(CertStore.getInstance("Collection", new CollectionCertStoreParameters())); @@ -793,13 +720,12 @@ * Assertion: if null, the store is ignored (not added to list) * @throws InvalidAlgorithmParameterException */ - public final void testAddCertStore02() - throws InvalidAlgorithmParameterException { + public final void testAddCertStore02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.addCertStore(null); assertTrue(p.getCertStores().isEmpty()); @@ -810,13 +736,12 @@ * Assertion: list ... may be empty, but not null * @throws InvalidAlgorithmParameterException */ - public final void testGetCertPathCheckers01() - throws InvalidAlgorithmParameterException { + public final void testGetCertPathCheckers01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); List l = p.getCertPathCheckers(); assertNotNull("notNull", l); @@ -829,24 +754,21 @@ * of PKIXCertPathCheckers * @throws InvalidAlgorithmParameterException */ - public final void testGetCertPathCheckers02() - throws InvalidAlgorithmParameterException { + public final void testGetCertPathCheckers02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); List l = p.getCertPathCheckers(); - boolean modificationFailed = false; + try { // try to modify returned list l.add(new Object()); + fail("must be immutable"); } catch (Exception e) { - modificationFailed = true; - logln(getName() + ": " + e); } - assertTrue(modificationFailed); } /** @@ -857,14 +779,12 @@ * @throws InvalidAlgorithmParameterException * @throws CertPathValidatorException */ - public final void testGetCertPathCheckers03() - throws InvalidAlgorithmParameterException, - CertPathValidatorException { + public final void testGetCertPathCheckers03() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); @@ -889,13 +809,12 @@ * certification path checkers * @throws InvalidAlgorithmParameterException */ - public final void testSetCertPathCheckers01() - throws InvalidAlgorithmParameterException { + public final void testSetCertPathCheckers01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); @@ -911,13 +830,12 @@ * Assertion: List ... may be null * @throws InvalidAlgorithmParameterException */ - public final void testSetCertPathCheckers02() - throws InvalidAlgorithmParameterException { + public final void testSetCertPathCheckers02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setCertPathCheckers(null); List l1 = p.getCertPathCheckers(); @@ -936,14 +854,13 @@ * against subsequent modifications * @throws InvalidAlgorithmParameterException */ - public final void testSetCertPathCheckers03() - throws InvalidAlgorithmParameterException { + public final void testSetCertPathCheckers03() throws Exception { // checks that list copied Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); @@ -966,15 +883,13 @@ * @throws InvalidAlgorithmParameterException * @throws CertPathValidatorException */ - public final void testSetCertPathCheckers04() - throws InvalidAlgorithmParameterException, - CertPathValidatorException { + public final void testSetCertPathCheckers04() throws Exception { // checks that checkers cloned Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); @@ -997,29 +912,24 @@ * java.security.cert.PKIXCertPathChecker * @throws InvalidAlgorithmParameterException */ - public final void testSetCertPathCheckers05() - throws InvalidAlgorithmParameterException { + public final void testSetCertPathCheckers05() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); assertTrue("addedOk", l.add(cpc)); // add wrong object to the list assertTrue("addedOk", l.add(new Object())); - boolean cceHasBeenThrown = false; + try { p.setCertPathCheckers(l); - } catch (Exception e) { - if (e instanceof ClassCastException) { - cceHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("ClassCastException expected"); + } catch (ClassCastException e) { } - assertTrue(cceHasBeenThrown); } /** @@ -1028,14 +938,12 @@ * list of CertPathCheckers * @throws CertPathValidatorException */ - public final void testAddCertPathChecker01() - throws InvalidAlgorithmParameterException, - CertPathValidatorException { + public final void testAddCertPathChecker01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); @@ -1060,13 +968,12 @@ * Assertion: if null, the checker is ignored (not added to list). * @throws InvalidAlgorithmParameterException */ - public final void testAddCertPathChecker02() - throws InvalidAlgorithmParameterException { + public final void testAddCertPathChecker02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); List l = new ArrayList(); @@ -1086,14 +993,12 @@ * @throws InvalidAlgorithmParameterException * @throws CertPathValidatorException */ - public final void testAddCertPathChecker03() - throws InvalidAlgorithmParameterException, - CertPathValidatorException { + public final void testAddCertPathChecker03() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + // checks that checkers cloned PKIXParameters p = new PKIXParameters(taSet); PKIXCertPathChecker cpc = TestUtils.getTestCertPathChecker(); @@ -1115,13 +1020,12 @@ * Assertion: the Date, or null if not set * @throws InvalidAlgorithmParameterException */ - public final void testGetDate01() - throws InvalidAlgorithmParameterException { + public final void testGetDate01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); // the Date has not been set // the method must return null @@ -1138,13 +1042,12 @@ * against subsequent modifications * @throws InvalidAlgorithmParameterException */ - public final void testGetDate02() - throws InvalidAlgorithmParameterException { + public final void testGetDate02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); Date currentDate = new Date(); p.setDate((Date)currentDate.clone()); @@ -1162,13 +1065,12 @@ * the certification path should be determined * @throws InvalidAlgorithmParameterException */ - public final void testSetDate01() - throws InvalidAlgorithmParameterException { + public final void testSetDate01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setDate(new Date(555L)); assertTrue(p.getDate().getTime() == 555L); @@ -1179,13 +1081,12 @@ * Assertion: Date may be null * @throws InvalidAlgorithmParameterException */ - public final void testSetDate02() - throws InvalidAlgorithmParameterException { + public final void testSetDate02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setDate(null); assertNull(p.getDate()); @@ -1196,13 +1097,12 @@ * Assertion: Date supplied here is copied to protect * against subsequent modifications */ - public final void testSetDate03() - throws InvalidAlgorithmParameterException { + public final void testSetDate03() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); Date toBeSet = new Date(555L); p.setDate(toBeSet); @@ -1219,13 +1119,12 @@ * Assertion: Never returns null * @throws InvalidAlgorithmParameterException */ - public final void testGetInitialPolicies01() - throws InvalidAlgorithmParameterException { + public final void testGetInitialPolicies01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertNotNull("notNull", p.getInitialPolicies()); assertTrue("isEmpty", p.getInitialPolicies().isEmpty()); @@ -1237,24 +1136,20 @@ * policy OIDs in String format
* @throws InvalidAlgorithmParameterException */ - public final void testGetInitialPolicies02() - throws InvalidAlgorithmParameterException { + public final void testGetInitialPolicies02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); Set s = p.getInitialPolicies(); - boolean modificationFailed = false; try { // try to modify returned set s.add(new Object()); + fail("must be immutable"); } catch (Exception e) { - modificationFailed = true; - logln(getName() + ": " + e); } - assertTrue(modificationFailed); } /** @@ -1263,13 +1158,12 @@ * identifiers (OID strings) * @throws InvalidAlgorithmParameterException */ - public final void testSetInitialPolicies01() - throws InvalidAlgorithmParameterException { + public final void testSetInitialPolicies01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + Set s = new HashSet(); s.add("1.2.3.4.5.6.7"); PKIXParameters p = new PKIXParameters(taSet); @@ -1282,13 +1176,12 @@ * Assertion: Set may be null * @throws InvalidAlgorithmParameterException */ - public final void testSetInitialPolicies02() - throws InvalidAlgorithmParameterException { + public final void testSetInitialPolicies02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setInitialPolicies(null); assertTrue(p.getInitialPolicies().isEmpty()); @@ -1298,13 +1191,12 @@ * Test #3 for setInitialPolicies(Set) method
* Assertion: Set may be empty */ - public final void testSetInitialPolicies03() - throws InvalidAlgorithmParameterException { + public final void testSetInitialPolicies03() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); p.setInitialPolicies(new HashSet()); assertTrue(p.getInitialPolicies().isEmpty()); @@ -1315,13 +1207,12 @@ * Assertion: Set is copied to protect against * subsequent modifications */ - public final void testSetInitialPolicies04() - throws InvalidAlgorithmParameterException { + public final void testSetInitialPolicies04() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + Set s = new HashSet(); s.add("1.2.3.4.5.6.7"); s.add("1.2.3.4.5.6.8"); @@ -1340,27 +1231,21 @@ * if any of the elements in the set are not of type String * @throws InvalidAlgorithmParameterException */ - public final void testSetInitialPolicies05() - throws InvalidAlgorithmParameterException { + public final void testSetInitialPolicies05() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + Set s = new HashSet(); s.add("1.2.3.4.5.6.7"); s.add(new Object()); PKIXParameters p = new PKIXParameters(taSet); - boolean cceHasBeenThrown = false; try { p.setInitialPolicies(s); - } catch (Exception e) { - if (e instanceof ClassCastException) { - cceHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("ClassCastException expected"); + } catch (ClassCastException e) { } - assertTrue(cceHasBeenThrown); } /** @@ -1369,13 +1254,12 @@ * (never null) * @throws InvalidAlgorithmParameterException */ - public final void testGetTrustAnchors01() - throws InvalidAlgorithmParameterException { + public final void testGetTrustAnchors01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); assertNotNull("notNull", p.getTrustAnchors()); } @@ -1386,24 +1270,20 @@ * (never null) * @throws InvalidAlgorithmParameterException */ - public final void testGetTrustAnchors02() - throws InvalidAlgorithmParameterException { + public final void testGetTrustAnchors02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); Set s = p.getTrustAnchors(); - boolean modificationFailed = false; try { // try to modify returned set s.add(new Object()); + fail("must be immutable"); } catch (Exception e) { - modificationFailed = true; - logln(getName() + ": " + e); } - assertTrue(modificationFailed); } /** @@ -1411,13 +1291,12 @@ * Assertion: Sets the Set of most-trusted CAs * @throws InvalidAlgorithmParameterException */ - public final void testSetTrustAnchors01() - throws InvalidAlgorithmParameterException { + public final void testSetTrustAnchors01() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + Set taSet1 = TestUtils.getTrustAnchorSet(); PKIXParameters p = new PKIXParameters(taSet); p.setTrustAnchors(taSet1); @@ -1431,25 +1310,19 @@ * (trustAnchors.isEmpty() == true) * @throws InvalidAlgorithmParameterException */ - public final void testSetTrustAnchors02() - throws InvalidAlgorithmParameterException { + public final void testSetTrustAnchors02() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); - boolean iapeHasBeenThrown = false; try { // use empty set p.setTrustAnchors(new HashSet()); - } catch (Exception e) { - if (e instanceof InvalidAlgorithmParameterException) { - iapeHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("InvalidAlgorithmParameterException expected"); + } catch (InvalidAlgorithmParameterException e) { } - assertTrue(iapeHasBeenThrown); } /** @@ -1457,25 +1330,19 @@ * Assertion: NullPointerException - * if the specified Set is null) */ - public final void testSetTrustAnchors03() - throws InvalidAlgorithmParameterException { + public final void testSetTrustAnchors03() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); - boolean npeHasBeenThrown = false; try { // use null p.setTrustAnchors(null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - npeHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("NPE expected"); + } catch (NullPointerException e) { } - assertTrue(npeHasBeenThrown); } /** @@ -1485,26 +1352,20 @@ * java.security.cert.TrustAnchor * @throws InvalidAlgorithmParameterException */ - public final void testSetTrustAnchors04() - throws InvalidAlgorithmParameterException { + public final void testSetTrustAnchors04() throws Exception { Set taSet = TestUtils.getTrustAnchorSet(); if (taSet == null) { - fail(getName() + ": PASSED (could not create test TrustAnchor set)"); - return; + fail(getName() + ": not performed (could not create test TrustAnchor set)"); } + PKIXParameters p = new PKIXParameters(taSet); Set s = new HashSet(p.getTrustAnchors()); s.add(new Object()); - boolean cceHasBeenThrown = false; try { p.setTrustAnchors(s); - } catch (Exception e) { - if (e instanceof ClassCastException) { - cceHasBeenThrown = true; - } - logln(getName() + ": " + e); + fail("ClassCastException expected"); + } catch (ClassCastException e) { } - assertTrue(cceHasBeenThrown); } /** @@ -1514,15 +1375,13 @@ * @throws InvalidAlgorithmParameterException * @throws KeyStoreException */ - public final void testSetTrustAnchors05() - throws KeyStoreException, - InvalidAlgorithmParameterException { + public final void testSetTrustAnchors05() throws Exception { // use several trusted certs in this test KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + PKIXParameters p = new PKIXParameters(ks); // prepare new Set HashSet newSet = new HashSet(p.getTrustAnchors()); @@ -1543,14 +1402,10 @@ * @throws InvalidAlgorithmParameterException * @throws NoSuchAlgorithmException */ - public final void testClone01() - throws KeyStoreException, - InvalidAlgorithmParameterException, - NoSuchAlgorithmException { + public final void testClone01() throws Exception { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } PKIXParameters p1 = new PKIXParameters(ks); @@ -1620,15 +1475,11 @@ * @throws InvalidAlgorithmParameterException * @throws NoSuchAlgorithmException */ - public final void testClone02() - throws KeyStoreException, - InvalidAlgorithmParameterException, - NoSuchAlgorithmException { + public final void testClone02() throws Exception { PKIXParameters[] p = new PKIXParameters[2]; KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } for (int i = 0; iCertPathValidator class methods. * */ -public class CertPathValidator3Test extends PerformanceTest { +public class CertPathValidator3Test extends TestCase { /** * Constructor for CertPathValidatorTests. Index: modules/security2/test/common/unit/java/security/cert/CertificateEncodingExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateEncodingExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateEncodingExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.cert.CertificateEncodingException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class CertificateEncodingExceptionTest extends PerformanceTest { +public class CertificateEncodingExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testCertificateEncodingException01() { CertificateEncodingException tE = new CertificateEncodingException(); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ CertificateEncodingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateEncodingException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateEncodingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testCertificateEncodingException03() { String msg = null; CertificateEncodingException tE = new CertificateEncodingException(msg); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -138,7 +134,6 @@ Throwable cause = null; CertificateEncodingException tE = new CertificateEncodingException( cause); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -156,7 +151,6 @@ public void testCertificateEncodingException05() { CertificateEncodingException tE = new CertificateEncodingException( tCause); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -181,7 +175,6 @@ public void testCertificateEncodingException06() { CertificateEncodingException tE = new CertificateEncodingException( null, null); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -200,8 +193,6 @@ CertificateEncodingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateEncodingException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateEncodingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -221,7 +212,6 @@ public void testCertificateEncodingException08() { CertificateEncodingException tE = new CertificateEncodingException( null, tCause); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -247,8 +237,6 @@ CertificateEncodingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateEncodingException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateEncodingException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CertPathTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertPathTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertPathTest.java (working copy) @@ -22,14 +22,14 @@ package java.security.cert; import org.apache.harmony.security.cert.MyCertPath; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for CertPath fields and methods * */ -public class CertPathTest extends PerformanceTest { +public class CertPathTest extends TestCase { /** * Meaningless cert path encoding just for testing purposes */ @@ -70,7 +70,7 @@ public final void testHashCode() { CertPath cp1 = new MyCertPath(testEncoding); CertPath cp2 = new MyCertPath(testEncoding); - logln(getName() + ": " + cp1.hashCode()); + assertTrue(cp1.hashCode() == cp2.hashCode()); } @@ -138,9 +138,7 @@ */ public final void testToString() { CertPath cp1 = new MyCertPath(testEncoding); - String rep = cp1.toString(); - logln(getName() + ": " + rep); - assertTrue(rep != null); + assertNotNull(cp1.toString()); } // Index: modules/security2/test/common/unit/java/security/cert/TrustAnchorTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/TrustAnchorTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/TrustAnchorTest.java (working copy) @@ -32,13 +32,13 @@ import org.apache.harmony.security.TestKeyPair; import org.apache.harmony.security.cert.TestUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Unit tests for TrustAnchor */ -public class TrustAnchorTest extends PerformanceTest { +public class TrustAnchorTest extends TestCase { private static final String keyAlg = "DSA"; // Sample of some valid CA name private static final String validCaNameRfc2253 = @@ -67,26 +67,26 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; // sub testcase 1 - TrustAnchor ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - getFullEncoding()); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + getFullEncoding()); // sub testcase 2 - ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - getEncodingPSOnly()); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + getEncodingPSOnly()); // sub testcase 3 - ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - getEncodingESOnly()); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + getEncodingESOnly()); // sub testcase 4 - ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - getEncodingNoMinMax()); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + getEncodingNoMinMax()); } /** @@ -99,13 +99,13 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; - TrustAnchor ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - null); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + null); } /** @@ -118,9 +118,9 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; byte[] nc = getEncodingPSOnly(); byte[] ncCopy = (byte[])nc.clone(); @@ -146,16 +146,13 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } - String certAlias = "testca1"; + try { - TrustAnchor ta = new TrustAnchor(null, getFullEncoding()); + new TrustAnchor(null, getFullEncoding()); fail("NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); - return; } } @@ -170,9 +167,9 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; // sub testcase 1: @@ -181,12 +178,11 @@ // set wrong root seq length nameConstraints[2] = (byte)0x8d; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } // sub testcase 2: @@ -195,12 +191,11 @@ // set wrong root seq length nameConstraints[2] = (byte)0x8b; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } // sub testcase 3: @@ -209,12 +204,11 @@ // remove right class from seq tag nameConstraints[3] &= (byte)0x3f; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } // sub testcase 4: @@ -223,12 +217,11 @@ // set wrong tagged value (excludedSubtrees SEQ OF) tag [2] nameConstraints[2] = (byte)0xa2; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } // sub testcase 5: @@ -237,12 +230,11 @@ // remove CONSTRUCTED flag from tagged value (excludedSubtrees SEQ OF) tag nameConstraints[2] &= (byte)0xdf; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } // sub testcase 6: @@ -252,12 +244,11 @@ // (generalSubtree's 'base' as IA5String) nameConstraints[5] |= (byte)0x20; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } // sub testcase 7: @@ -268,12 +259,11 @@ nameConstraints[12] = nameConstraints[13] = nameConstraints[14] = (byte)0x6f; try { - TrustAnchor ta = new TrustAnchor( + new TrustAnchor( (X509Certificate)ks.getCertificate(certAlias), nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } } @@ -287,14 +277,14 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; byte [] nameConstraints = getEncodingOid(); - TrustAnchor ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - nameConstraints); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + nameConstraints); } /** @@ -308,20 +298,19 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; byte [] nameConstraints = getEncodingOid(); //corrupt Oid nameConstraints[10]= (byte) 0xFF; try { - TrustAnchor ta = new TrustAnchor( - (X509Certificate)ks.getCertificate(certAlias), - nameConstraints); + new TrustAnchor( + (X509Certificate)ks.getCertificate(certAlias), + nameConstraints); fail("IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } } @@ -336,9 +325,9 @@ throws KeyStoreException { KeyStore ks = TestUtils.getKeyStore(true, TestUtils.TRUSTED); if (ks == null) { - fail(getName() + ": PASSED (could not create test KeyStore)"); - return; + fail(getName() + ": not performed (could not create test KeyStore)"); } + String certAlias = "testca1"; // GeneralName tags for this test (1,2 and 3 are omitted) byte[] generalNameTag = new byte[] { @@ -358,13 +347,12 @@ for (int i=0; iDigestException class constructors and methods. * */ -public class CertificateExpiredExceptionTest extends PerformanceTest { +public class CertificateExpiredExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertificateExpiredException01() { CertificateExpiredException tE = new CertificateExpiredException(); - assertTrue(errNotExc, tE instanceof CertificateExpiredException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertificateExpiredException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateExpiredException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateExpiredException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testCertificateExpiredException03() { String msg = null; CertificateExpiredException tE = new CertificateExpiredException(msg); - assertTrue(errNotExc, tE instanceof CertificateExpiredException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/java/security/cert/CertificateNotYetValidExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateNotYetValidExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateNotYetValidExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.cert.CertificateNotYetValidException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class CertificateNotYetValidExceptionTest extends PerformanceTest { +public class CertificateNotYetValidExceptionTest extends TestCase { public static void main(String[] args) { } @@ -80,7 +80,6 @@ */ public void testCertificateNotYetValidException01() { CertificateNotYetValidException tE = new CertificateNotYetValidException(); - assertTrue(errNotExc, tE instanceof CertificateNotYetValidException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -99,8 +98,6 @@ CertificateNotYetValidException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateNotYetValidException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateNotYetValidException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -121,7 +118,6 @@ String msg = null; CertificateNotYetValidException tE = new CertificateNotYetValidException( msg); - assertTrue(errNotExc, tE instanceof CertificateNotYetValidException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/java/security/cert/CertificateParsingExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateParsingExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateParsingExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.cert.CertificateParsingException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class CertificateParsingExceptionTest extends PerformanceTest { +public class CertificateParsingExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testCertificateParsingException01() { CertificateParsingException tE = new CertificateParsingException(); - assertTrue(errNotExc, tE instanceof CertificateParsingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ CertificateParsingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateParsingException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateParsingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testCertificateParsingException03() { String msg = null; CertificateParsingException tE = new CertificateParsingException(msg); - assertTrue(errNotExc, tE instanceof CertificateParsingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -137,7 +133,6 @@ public void testCertificateParsingException04() { Throwable cause = null; CertificateParsingException tE = new CertificateParsingException(cause); - assertTrue(errNotExc, tE instanceof CertificateParsingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -154,7 +149,6 @@ */ public void testCertificateParsingException05() { CertificateParsingException tE = new CertificateParsingException(tCause); - assertTrue(errNotExc, tE instanceof CertificateParsingException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -179,7 +173,6 @@ public void testCertificateParsingException06() { CertificateParsingException tE = new CertificateParsingException(null, null); - assertTrue(errNotExc, tE instanceof CertificateParsingException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -198,8 +191,6 @@ CertificateParsingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateParsingException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateParsingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -219,7 +210,6 @@ public void testCertificateParsingException08() { CertificateParsingException tE = new CertificateParsingException(null, tCause); - assertTrue(errNotExc, tE instanceof CertificateParsingException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -245,8 +235,6 @@ CertificateParsingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateParsingException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateParsingException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/cert/CertificateFactorySpiTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateFactorySpiTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateFactorySpiTest.java (working copy) @@ -29,14 +29,14 @@ import java.util.Iterator; import java.util.List; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for CertificateFactorySpi class constructors and methods * */ -public class CertificateFactorySpiTest extends PerformanceTest { +public class CertificateFactorySpiTest extends TestCase { /** * Constructor for CertStoreSpiTest. * Index: modules/security2/test/common/unit/java/security/cert/CertStoreSpiTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertStoreSpiTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertStoreSpiTest.java (working copy) @@ -24,7 +24,7 @@ import java.security.InvalidAlgorithmParameterException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import junit.framework.Test; import junit.framework.TestSuite; @@ -34,7 +34,7 @@ * */ -public class CertStoreSpiTest extends PerformanceTest { +public class CertStoreSpiTest extends TestCase { /** * Constructor for CertStoreSpiTest. Index: modules/security2/test/common/unit/java/security/cert/PKIXCertPathCheckerTest.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/PKIXCertPathCheckerTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/PKIXCertPathCheckerTest.java (working copy) @@ -25,14 +25,14 @@ import org.apache.harmony.security.cert.MyCertificate; import org.apache.harmony.security.cert.TestUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PKIXCertPathChecker * */ -public class PKIXCertPathCheckerTest extends PerformanceTest { +public class PKIXCertPathCheckerTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/cert/CertificateFactory2Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertificateFactory2Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertificateFactory2Test.java (working copy) @@ -32,7 +32,7 @@ import java.util.List; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -40,7 +40,7 @@ * */ -public class CertificateFactory2Test extends PerformanceTest { +public class CertificateFactory2Test extends TestCase { private static final String defaultAlg = "CertFac"; private static final String CertificateFactoryProviderClass = "java.security.cert.MyCertificateFactorySpi"; Index: modules/security2/test/common/unit/java/security/cert/CertStore2Test.java =================================================================== --- modules/security2/test/common/unit/java/security/cert/CertStore2Test.java (revision 373503) +++ modules/security2/test/common/unit/java/security/cert/CertStore2Test.java (working copy) @@ -29,7 +29,7 @@ import java.util.Collection; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -37,7 +37,7 @@ * */ -public class CertStore2Test extends PerformanceTest { +public class CertStore2Test extends TestCase { private static final String defaultAlg = "CertStore"; private static final String CertStoreProviderClass = "java.security.cert.MyCertStoreSpi"; Index: modules/security2/test/common/unit/java/security/InvalidKeyExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/InvalidKeyExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/InvalidKeyExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.InvalidKeyException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for InvalidKeyException class constructors and methods. * */ -public class InvalidKeyExceptionTest extends PerformanceTest { +public class InvalidKeyExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testInvalidKeyException01() { InvalidKeyException tE = new InvalidKeyException(); - assertTrue(errNotExc, tE instanceof InvalidKeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ InvalidKeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidKeyException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidKeyException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testInvalidKeyException03() { String msg = null; InvalidKeyException tE = new InvalidKeyException(msg); - assertTrue(errNotExc, tE instanceof InvalidKeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -135,7 +131,6 @@ public void testInvalidKeyException04() { Throwable cause = null; InvalidKeyException tE = new InvalidKeyException(cause); - assertTrue(errNotExc, tE instanceof InvalidKeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -152,7 +147,6 @@ */ public void testInvalidKeyException05() { InvalidKeyException tE = new InvalidKeyException(tCause); - assertTrue(errNotExc, tE instanceof InvalidKeyException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -176,7 +170,6 @@ */ public void testInvalidKeyException06() { InvalidKeyException tE = new InvalidKeyException(null, null); - assertTrue(errNotExc, tE instanceof InvalidKeyException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -195,8 +188,6 @@ InvalidKeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidKeyException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidKeyException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -215,7 +206,6 @@ */ public void testInvalidKeyException08() { InvalidKeyException tE = new InvalidKeyException(null, tCause); - assertTrue(errNotExc, tE instanceof InvalidKeyException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -241,8 +231,6 @@ InvalidKeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidKeyException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidKeyException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/CodeSignerTest.java =================================================================== --- modules/security2/test/common/unit/java/security/CodeSignerTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/CodeSignerTest.java (working copy) @@ -25,14 +25,14 @@ import java.util.Date; import org.apache.harmony.security.TestCertUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Unit test for CodeSigner. */ -public class CodeSignerTest extends PerformanceTest { +public class CodeSignerTest extends TestCase { /** * Entry point for standalone runs. Index: modules/security2/test/common/unit/java/security/SignatureTest2.java =================================================================== --- modules/security2/test/common/unit/java/security/SignatureTest2.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SignatureTest2.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for Signature constructor and methods * */ -public class SignatureTest2 extends PerformanceTest { +public class SignatureTest2 extends TestCase { /** * Provider Index: modules/security2/test/common/unit/java/security/KeyStoreTest1.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyStoreTest1.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyStoreTest1.java (working copy) @@ -33,14 +33,14 @@ import org.apache.harmony.security.SpiEngUtils; import org.apache.harmony.security.TestKeyPair; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyStore constructor and methods * */ -public class KeyStoreTest1 extends PerformanceTest { +public class KeyStoreTest1 extends TestCase { public static final String srvKeyStore = "KeyStore"; public static String[] validValues = { @@ -156,7 +156,6 @@ KeyStore ks; for (int i = 0; i < validValues.length; i++) { ks = KeyStore.getInstance(validValues[i]); - assertTrue("Not KeyStore object", ks instanceof KeyStore); assertEquals("Incorrect type", ks.getType(), validValues[i]); } } @@ -251,7 +250,6 @@ KeyStore ks; for (int i = 0; i < validValues.length; i++) { ks = KeyStore.getInstance(validValues[i], defaultProviderName); - assertTrue("Not KeyStore object", ks instanceof KeyStore); assertEquals("Incorrect type", ks.getType(), validValues[i]); assertEquals("Incorrect provider", ks.getProvider().getName(), defaultProviderName); @@ -320,7 +318,6 @@ KeyStore ks; for (int i = 0; i < validValues.length; i++) { ks = KeyStore.getInstance(validValues[i], defaultProvider); - assertTrue("not KeyStore object", ks instanceof KeyStore); assertEquals("Incorrect type", ks.getType(), validValues[i]); assertEquals("Incorrect provider", ks.getProvider(), defaultProvider); @@ -660,26 +657,19 @@ kss[i].setEntry("ZZZ", pKey, pPath); fail("KeyStoreException should be thrown because password is destroyed"); } catch (KeyStoreException e) { - } catch (IllegalStateException e) { - logln("testEntry02: setEntry(..) throws IllegalStateException instead of " - + "KeyStoreException for destroyed password"); } + for (int j = 0; j < aliases.length; j++) { try { kss[i].getEntry(aliases[j], pPath); fail("KeyStoreException should be thrown because password is destroyed"); } catch (KeyStoreException e) { - } catch (IllegalStateException e) { - logln("testEntry02: getEntry(..) throws IllegalStateExceptioninstead of " - +"KeyStoreException for destroyed password"); } + try { kss[i].getEntry(aliases[j], pPar); fail("UnrecoverableEntryExceptionn should be thrown"); } catch (UnrecoverableEntryException e) { - } catch (UnsupportedOperationException e) { - logln("testEntry02: getEntry(..) throws UnsupportedOperationException, " - + "but expected UnrecoverableEntryException"); } } } @@ -727,11 +717,11 @@ try { kss[i].setEntry(aliases[j], sKey, pPath); } catch (KeyStoreException e) { - logln("testEntry03: non-PrivateKeys not supported."); - return; + //logln("testEntry03: non-PrivateKeys not supported."); + return; } } - KeyStore.Entry en; + for (int j = 0; j < aliases.length; j++) { assertTrue("Incorrect alias", kss[i].containsAlias(aliases[j])); assertTrue("Not KeyEntry", kss[i].isKeyEntry(aliases[j])); @@ -740,7 +730,7 @@ try { key1 = kss[i].getKey(aliases[j], pwd); } catch (UnrecoverableKeyException e) { - logln("testEntry03: non-PrivateKeys not supported."); + //logln("testEntry03: non-PrivateKeys not supported."); return; } if (!secKey.getAlgorithm().equals(key1.getAlgorithm()) || @@ -904,19 +894,14 @@ fail("KeyStoreException or IllegalArgumentException should be thrown " + "when chain is null and key is private"); } catch (KeyStoreException e) { - } catch (IllegalArgumentException e) { - logln("testEntry05: setKeyEntry throws IllegalArgumentException for " - + "private key and null chain"); } try { kss[i].setKeyEntry("ZZZ", key, pwd, new MCertificate[0]); fail("KeyStoreException or IllegalArgumentException should be thrown " + "when chain is empty and key is private"); } catch (KeyStoreException e) { - } catch (IllegalArgumentException e) { - logln("testEntry05: setKeyEntry throws IllegalArgumentException " - + "for private key and emptyl chain"); } + for (int j = 0; j < aliases.length; j++) { kss[i].setKeyEntry(aliases[j], key, pwd, certs); } @@ -968,8 +953,8 @@ assertEquals("Incorrect certificate", cc[t], certs[t]); } } - assertEquals(kss[i].getCertificateAlias((Certificate)cert), null); - String ss = kss[i].getCertificateAlias((Certificate)certs[0]); + assertEquals(kss[i].getCertificateAlias(cert), null); + String ss = kss[i].getCertificateAlias(certs[0]); boolean ans = false; for (int j = 1; j < aliases.length; j++) { if (ss.equals(aliases[j])) { @@ -1079,7 +1064,7 @@ char [] pwd = {'p', 'a', 's', 's', 'w', 'd'}; String aliasKE = "KeyAlias"; KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(pwd); - KeyStore.PasswordProtection anotherPath = new KeyStore.PasswordProtection(new char[0]); + new KeyStore.PasswordProtection(new char[0]); KeyStore [] kss = createKS(); assertNotNull("KeyStore objects were not created", kss); @@ -1126,7 +1111,6 @@ KeyStoreSpi spi = new MyKeyStoreSpi(); KeyStore keySt = new tmpKeyStore(spi, defaultProvider, defaultType); - assertTrue("Not CertStore object", keySt instanceof KeyStore); assertEquals("Incorrect name", keySt.getType(), defaultType); assertEquals("Incorrect provider", keySt.getProvider(), defaultProvider); @@ -1137,7 +1121,6 @@ } catch (KeyStoreException e) { } keySt = new tmpKeyStore(null, null, null); - assertTrue("Not CertStore object", keySt instanceof KeyStore); assertNull("Aalgorithm must be null", keySt.getType()); assertNull("Provider must be null", keySt.getProvider()); try { Index: modules/security2/test/common/unit/java/security/SignerTest.java =================================================================== --- modules/security2/test/common/unit/java/security/SignerTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SignerTest.java (working copy) @@ -22,7 +22,7 @@ package java.security; import org.apache.harmony.security.*; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; @@ -31,7 +31,7 @@ * */ -public class SignerTest extends PerformanceTest { +public class SignerTest extends TestCase { public static class MySecurityManager extends SecurityManager { public Permissions denied = new Permissions(); @@ -71,18 +71,18 @@ * verify Signer.toString() */ public void testToString() throws Exception { -// java.util.Enumeration e = IdentityScope.getSystemScope().identities(); -// while(e.hasMoreElements()) System.out.println(e.nextElement()); - Signer s1 = new SignerStub("testToString1"); - logln(s1.toString()); + s1.toString(); + Signer s2 = new SignerStub("testToString2", IdentityScope.getSystemScope()); - logln(s2.toString()); + s2.toString(); + KeyPair kp = new KeyPair(new PublicKeyStub("public", "SignerTest.testToString", null), new PrivateKeyStub("private", "SignerTest.testToString", null)); s1.setKeyPair(kp); - logln(s1.toString()); + s1.toString(); + s2.setKeyPair(kp); - logln(s2.toString()); + s2.toString(); } /** Index: modules/security2/test/common/unit/java/security/BasicPermissionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/BasicPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/BasicPermissionTest.java (working copy) @@ -21,14 +21,14 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for BasicPermission * */ -public class BasicPermissionTest extends PerformanceTest { +public class BasicPermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(BasicPermissionTest.class); Index: modules/security2/test/common/unit/java/security/ProviderTest.java =================================================================== --- modules/security2/test/common/unit/java/security/ProviderTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/ProviderTest.java (working copy) @@ -31,7 +31,7 @@ import java.util.Map.Entry; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.test.TestUtils; @@ -39,7 +39,7 @@ * Tests for Provider constructor and methods * */ -public class ProviderTest extends PerformanceTest { +public class ProviderTest extends TestCase { Provider p; Index: modules/security2/test/common/unit/java/security/AllPermissionCollectionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/AllPermissionCollectionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AllPermissionCollectionTest.java (working copy) @@ -24,7 +24,7 @@ import java.util.Enumeration; import java.util.NoSuchElementException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -32,7 +32,7 @@ * */ -public class AllPermissionCollectionTest extends PerformanceTest { +public class AllPermissionCollectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AllPermissionCollectionTest.class); Index: modules/security2/test/common/unit/java/security/KeyPairGeneratorTest3.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyPairGeneratorTest3.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyPairGeneratorTest3.java (working copy) @@ -25,7 +25,7 @@ import java.security.NoSuchProviderException; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -33,7 +33,7 @@ * */ -public class KeyPairGeneratorTest3 extends PerformanceTest { +public class KeyPairGeneratorTest3 extends TestCase { /** * Constructor for KeyPairGeneratorTest3. @@ -101,9 +101,7 @@ for (int i = 0; i < kpg.length; i++) { kpg[i].initialize(512, rr); kp = kpg[i].generateKeyPair(); - assertTrue("Not KeyPair object", kp instanceof KeyPair); kp1 = kpg[i].genKeyPair(); - assertTrue("Not KeyPair object", kp1 instanceof KeyPair); assertFalse("Incorrect private key", kp.getPrivate().equals( kp1.getPrivate())); assertFalse("Incorrect public key", kp.getPublic().equals( @@ -126,19 +124,12 @@ assertNotNull("KeyPairGenerator objects were not created", kpg); KeyPair kp, kp1; for (int i = 0; i < kpg.length; i++) { - try { - kp = kpg[i].generateKeyPair(); - assertTrue("Not KeyPair object", kp instanceof KeyPair); - kp1 = kpg[i].genKeyPair(); - assertTrue("Not KeyPair object", kp1 instanceof KeyPair); - assertFalse("Incorrect private key", kp.getPrivate().equals( - kp1.getPrivate())); - assertFalse("Incorrect public key", kp.getPublic().equals( - kp1.getPublic())); - } catch (Exception e) { - logln("Unexpected exception was thrown during KeyPair " - + " generation without previous initialization"); - } + kp = kpg[i].generateKeyPair(); + kp1 = kpg[i].genKeyPair(); + assertFalse("Incorrect private key", kp.getPrivate().equals( + kp1.getPrivate())); + assertFalse("Incorrect public key", kp.getPublic().equals( + kp1.getPublic())); } } Index: modules/security2/test/common/unit/java/security/PolicyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/PolicyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/PolicyTest.java (working copy) @@ -26,7 +26,7 @@ import java.util.HashSet; import org.apache.harmony.security.fortress.DefaultPolicy; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.test.SecurityChecker; @@ -35,7 +35,7 @@ * */ -public class PolicyTest extends PerformanceTest { +public class PolicyTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(PolicyTest.class); Index: modules/security2/test/common/unit/java/security/UnresolvedPermissionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/UnresolvedPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/UnresolvedPermissionTest.java (working copy) @@ -21,14 +21,14 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for UnresolvedPermission class fields and methods * */ -public class UnresolvedPermissionTest extends PerformanceTest { +public class UnresolvedPermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(UnresolvedPermissionTest.class); Index: modules/security2/test/common/unit/java/security/KSPrivateKeyEntryTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KSPrivateKeyEntryTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KSPrivateKeyEntryTest.java (working copy) @@ -25,7 +25,7 @@ import java.security.cert.Certificate; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import junit.framework.Test; import junit.framework.TestSuite; @@ -35,7 +35,7 @@ * */ -public class KSPrivateKeyEntryTest extends PerformanceTest { +public class KSPrivateKeyEntryTest extends TestCase { /** * Constructor for KSPrivateKeyEntryTest. @@ -65,7 +65,7 @@ * Assertion: throws NullPointerException when privateKey is null */ public void testPrivateKeyEntry01() { - Certificate[] certs = (Certificate[]) new MyCertificate[1];//new Certificate[1]; + Certificate[] certs = new MyCertificate[1];//new Certificate[1]; PrivateKey pk = null; try { new KeyStore.PrivateKeyEntry(pk, certs); @@ -133,8 +133,6 @@ createParams(false, false); KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry( testPrivateKey, testChain); - assertTrue("Not KeyStore.PrivateKeyEntry object", - ksPKE instanceof KeyStore.PrivateKeyEntry); assertEquals("Incorrect PrivateKey", testPrivateKey, ksPKE .getPrivateKey()); } @@ -147,8 +145,6 @@ createParams(false, false); KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry( testPrivateKey, testChain); - assertTrue("Not KeyStore.PrivateKeyEntry object", - ksPKE instanceof KeyStore.PrivateKeyEntry); Certificate[] res = ksPKE.getCertificateChain(); assertEquals("Incorrect chain length", testChain.length, res.length); for (int i = 0; i < res.length; i++) { @@ -165,8 +161,6 @@ createParams(false, false); KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry( testPrivateKey, testChain); - assertTrue("Not KeyStore.PrivateKeyEntry object", - ksPKE instanceof KeyStore.PrivateKeyEntry); Certificate res = ksPKE.getCertificate(); assertEquals("Incorrect end certificate (number 0)", testChain[0], res); } @@ -179,11 +173,8 @@ createParams(false, false); KeyStore.PrivateKeyEntry ksPKE = new KeyStore.PrivateKeyEntry( testPrivateKey, testChain); - assertTrue("Not KeyStore.PrivateKeyEntry object", - ksPKE instanceof KeyStore.PrivateKeyEntry); String res = ksPKE.toString(); assertNotNull("toString() returns null", res); - logln(res); } public static Test suite() { Index: modules/security2/test/common/unit/java/security/PermissionCollectionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/PermissionCollectionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/PermissionCollectionTest.java (working copy) @@ -23,7 +23,7 @@ import java.util.*; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * */ -public class PermissionCollectionTest extends PerformanceTest { +public class PermissionCollectionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(PermissionCollectionTest.class); Index: modules/security2/test/common/unit/java/security/KeyPairTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyPairTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyPairTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.spec.InvalidKeySpecException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for fields and methods of class KeyPair * */ -public class KeyPairTest extends PerformanceTest { +public class KeyPairTest extends TestCase { private static class TestKeyPair { static PublicKey getPublic() { Index: modules/security2/test/common/unit/java/security/SecurityTest.java =================================================================== --- modules/security2/test/common/unit/java/security/SecurityTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SecurityTest.java (working copy) @@ -26,14 +26,14 @@ import java.util.Set; import org.apache.harmony.security.TestKeyPair; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for Security constructor and methods * */ -public class SecurityTest extends PerformanceTest { +public class SecurityTest extends TestCase { public final void testMixed() { Index: modules/security2/test/common/unit/java/security/spec/ECFieldF2mTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECFieldF2mTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECFieldF2mTest.java (working copy) @@ -24,25 +24,16 @@ import java.math.BigInteger; import java.util.Arrays; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECFieldF2m class fields and methods. * */ -public class ECFieldF2mTest extends PerformanceTest { +public class ECFieldF2mTest extends TestCase { /** - * PASSED - test status 'passed' - */ - private static final long PASSED = 0L; - /** - * FAILED - test status 'failed' - */ - private static final long FAILED = 1L; - - /** * Support class for this test. * Incapsulates ECFieldF2m testing * domain parameters. @@ -156,36 +147,27 @@ * Assertion: IllegalArgumentException if m is not positive. */ public final void testECFieldF2mint() { - long result = PASSED; for(int i=0; iRSAOtherPrimeInfo class fields and methods. * */ -public class RSAOtherPrimeInfoTest extends PerformanceTest { +public class RSAOtherPrimeInfoTest extends TestCase { /* * @see TestCase#setUp() @@ -72,19 +72,13 @@ * Assertion: NullPointerException if prime is null */ public final void testRSAOtherPrimeInfo02() { - boolean passed = false; try { - RSAOtherPrimeInfo ropi = - new RSAOtherPrimeInfo(null, - BigInteger.valueOf(2L), - BigInteger.valueOf(3L)); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + new RSAOtherPrimeInfo(null, + BigInteger.valueOf(2L), + BigInteger.valueOf(3L)); + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -92,19 +86,13 @@ * Assertion: NullPointerException if primeExponent is null */ public final void testRSAOtherPrimeInfo03() { - boolean passed = false; try { - RSAOtherPrimeInfo ropi = - new RSAOtherPrimeInfo(BigInteger.valueOf(1L), - null, - BigInteger.valueOf(3L)); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + new RSAOtherPrimeInfo(BigInteger.valueOf(1L), + null, + BigInteger.valueOf(3L)); + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -112,19 +100,13 @@ * Assertion: NullPointerException if crtCoefficient is null */ public final void testRSAOtherPrimeInfo04() { - boolean passed = false; try { - RSAOtherPrimeInfo ropi = - new RSAOtherPrimeInfo(BigInteger.valueOf(1L), - BigInteger.valueOf(2L), - null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + new RSAOtherPrimeInfo(BigInteger.valueOf(1L), + BigInteger.valueOf(2L), + null); + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -132,19 +114,13 @@ * Assertion: NullPointerException if prime and crtCoefficient is null */ public final void testRSAOtherPrimeInfo05() { - boolean passed = false; try { - RSAOtherPrimeInfo ropi = - new RSAOtherPrimeInfo(null, - BigInteger.valueOf(2L), - null); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + new RSAOtherPrimeInfo(null, + BigInteger.valueOf(2L), + null); + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** Index: modules/security2/test/common/unit/java/security/spec/ECPointTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECPointTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECPointTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECPoint class fields and methods. * */ -public class ECPointTest extends PerformanceTest { +public class ECPointTest extends TestCase { /* * @see TestCase#setUp() @@ -65,11 +65,11 @@ * Expected: must pass without any exceptions */ public final void testECPoint01() { - ECPoint p = new ECPoint(BigInteger.ZERO, BigInteger.ZERO); - p = new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(-23456L)); - p = new ECPoint(BigInteger.valueOf(123456L), BigInteger.valueOf(123456L)); - p = new ECPoint(BigInteger.valueOf(-56L), BigInteger.valueOf(234L)); - p = new ECPoint(BigInteger.valueOf(3456L), BigInteger.valueOf(-2344L)); + new ECPoint(BigInteger.ZERO, BigInteger.ZERO); + new ECPoint(BigInteger.valueOf(-23456L), BigInteger.valueOf(-23456L)); + new ECPoint(BigInteger.valueOf(123456L), BigInteger.valueOf(123456L)); + new ECPoint(BigInteger.valueOf(-56L), BigInteger.valueOf(234L)); + new ECPoint(BigInteger.valueOf(3456L), BigInteger.valueOf(-2344L)); } /** @@ -80,35 +80,28 @@ * Expected: must throw NullPointerException */ public final void testECPoint02() { - boolean passed=false; // test case 1: x is null try { - ECPoint p = new ECPoint(null, BigInteger.ZERO); + new ECPoint(null, BigInteger.ZERO); + fail("#1: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); - passed=false; + // test case 2: y is null try { - ECPoint p = new ECPoint(BigInteger.ZERO, null); + new ECPoint(BigInteger.ZERO, null); + fail("#2: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); - passed=false; + // test case 3: both : x and y are null try { - ECPoint p = new ECPoint(null, null); + new ECPoint(null, null); + fail("#3: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -227,7 +220,6 @@ public final void testHashCode01() { ECPoint f = new ECPoint(BigInteger.valueOf(-23457L), BigInteger.ONE); int hc = f.hashCode(); - logln(getName() + ": " + hc); assertTrue(hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && @@ -236,10 +228,10 @@ hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode()); + // the same for POINT_INFINITY hc = ECPoint.POINT_INFINITY.hashCode(); - logln(getName() + ": " + hc); assertTrue(hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && hc == ECPoint.POINT_INFINITY.hashCode() && Index: modules/security2/test/common/unit/java/security/spec/ECParameterSpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECParameterSpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECParameterSpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECParameterSpec class fields and methods. * */ -public class ECParameterSpecTest extends PerformanceTest { +public class ECParameterSpecTest extends TestCase { /* * @see TestCase#setUp() @@ -76,8 +76,7 @@ BigInteger.ZERO, BigInteger.valueOf(4L)); ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); - AlgorithmParameterSpec ps = - new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10); + new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10); } /** @@ -95,49 +94,37 @@ BigInteger.valueOf(4L)); ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); BigInteger order = BigInteger.valueOf(5L); + // Test case 1: curve is null - boolean passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(null, generator, order, 10); + new ECParameterSpec(null, generator, order, 10); + fail("#1: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 2: generator is null - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, null, order, 10); + new ECParameterSpec(curve, null, order, 10); + fail("#2: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 3: order is null - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, generator, null, 10); + new ECParameterSpec(curve, generator, null, 10); + fail("#3: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 4: all above are null - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(null, null, null, 10); + new ECParameterSpec(null, null, null, 10); + fail("#4: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -154,65 +141,46 @@ BigInteger.ZERO, BigInteger.valueOf(4L)); ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); + + // Test case 1: order is negative - boolean passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, generator, - BigInteger.valueOf(-5L), 10); + new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 10); + fail("#1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 2: order == 0 - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, generator, - BigInteger.ZERO, 10); + new ECParameterSpec(curve, generator, BigInteger.ZERO, 10); + fail("#2: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 3: cofactor is negative - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, generator, - BigInteger.valueOf(5L), -10); + new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), -10); + fail("#3: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 4: cofactor == 0 - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, generator, - BigInteger.valueOf(5L), 0); + new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), 0); + fail("#4: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 5: both order and cofactor are not positive - passed = false; try { - AlgorithmParameterSpec ps = - new ECParameterSpec(curve, generator, - BigInteger.valueOf(-5L), 0); + new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 0); + fail("#5: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** Index: modules/security2/test/common/unit/java/security/spec/RSAKeyGenParameterSpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/RSAKeyGenParameterSpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/RSAKeyGenParameterSpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAKeyGenParameterSpec class fields and methods. * */ -public class RSAKeyGenParameterSpecTest extends PerformanceTest { +public class RSAKeyGenParameterSpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/RSAPrivateKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/RSAPrivateKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/RSAPrivateKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAPrivateKeySpec class fields and methods * */ -public class RSAPrivateKeySpecTest extends PerformanceTest { +public class RSAPrivateKeySpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/MGF1ParameterSpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/MGF1ParameterSpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/MGF1ParameterSpecTest.java (working copy) @@ -21,13 +21,13 @@ package java.security.spec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Test for MGF1ParameterSpec class * */ -public class MGF1ParameterSpecTest extends PerformanceTest { +public class MGF1ParameterSpecTest extends TestCase { /** * Meaningless algorithm name just for testing purposes @@ -66,7 +66,7 @@ * object using valid parameter */ public final void testMGF1ParameterSpec01() { - AlgorithmParameterSpec aps = new MGF1ParameterSpec(testAlgName); + new MGF1ParameterSpec(testAlgName); } /** @@ -75,10 +75,9 @@ */ public final void testMGF1ParameterSpec02() { try { - AlgorithmParameterSpec aps = new MGF1ParameterSpec(null); + new MGF1ParameterSpec(null); fail("NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } } Index: modules/security2/test/common/unit/java/security/spec/ECPrivateKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECPrivateKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECPrivateKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECPrivateKeySpec class fields and methods. * */ -public class ECPrivateKeySpecTest extends PerformanceTest { +public class ECPrivateKeySpecTest extends TestCase { /* * @see TestCase#setUp() @@ -76,9 +76,8 @@ BigInteger.ZERO, BigInteger.valueOf(4L)); ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); - ECPrivateKeySpec ks = - new ECPrivateKeySpec(BigInteger.ZERO, - new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); + new ECPrivateKeySpec(BigInteger.ZERO, + new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); } @@ -98,36 +97,28 @@ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); // Test case 1: s is null - boolean passed = false; try { - ECPrivateKeySpec ks = new ECPrivateKeySpec(null, + new ECPrivateKeySpec(null, new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); + fail("#1: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 2: params is null - passed = false; try { - ECPrivateKeySpec ks = new ECPrivateKeySpec(BigInteger.valueOf(0L), - null); + new ECPrivateKeySpec(BigInteger.valueOf(0L), null); + fail("#2: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 3: both s and params are null - passed = false; try { - ECPrivateKeySpec ks = new ECPrivateKeySpec(null, null); + new ECPrivateKeySpec(null, null); + fail("#3: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** Index: modules/security2/test/common/unit/java/security/spec/RSAPublicKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/RSAPublicKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/RSAPublicKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAPublicKeySpec class fields and methods * */ -public class RSAPublicKeySpecTest extends PerformanceTest { +public class RSAPublicKeySpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/EllipticCurveTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/EllipticCurveTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/EllipticCurveTest.java (working copy) @@ -24,14 +24,14 @@ import java.math.BigInteger; import java.util.Arrays; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for EllipticCurve class fields and methods. * */ -public class EllipticCurveTest extends PerformanceTest { +public class EllipticCurveTest extends TestCase { /* * @see TestCase#setUp() @@ -73,14 +73,14 @@ BigInteger b = BigInteger.valueOf(19L); byte[] seed = new byte[24]; // perform test case 1 - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); // test case 2 parameters set ECFieldF2m f1 = new ECFieldF2m(5); a = BigInteger.ZERO; b = BigInteger.valueOf(23L); // perform test case 2 - c = new EllipticCurve(f1, a, b, seed); + new EllipticCurve(f1, a, b, seed); // test case 3 parameters set, // the seed parameter may be null @@ -89,7 +89,7 @@ b = BigInteger.valueOf(19L); seed = null; // perform test case 3 - c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); } /** @@ -101,22 +101,20 @@ * Expected: must throw NullPointerException */ public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray02() { - boolean passed=false; // test case 1 parameters set ECFieldFp f = null; BigInteger a = BigInteger.ONE; BigInteger b = BigInteger.valueOf(19L); byte[] seed = new byte[24]; + // perform test case 1 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#1: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); - passed=false; + // test case 2 parameters set, f = new ECFieldFp(BigInteger.valueOf(23L)); a = null; @@ -124,28 +122,23 @@ seed = new byte[24]; // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#2: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); // test case 3 parameters set, - passed=false; f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.ONE; b = null; seed = new byte[24]; // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#3: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -159,69 +152,60 @@ * Expected: must throw IllegalArgumentException */ public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray03() { - boolean passed=false; // test case 1 parameters set, // a is not in field ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L)); BigInteger a = BigInteger.valueOf(24L); BigInteger b = BigInteger.valueOf(19L); byte[] seed = new byte[24]; + // perform test case 1 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); - passed=false; + // test case 1.1 parameters set, // b is not in field f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.valueOf(1L); b = BigInteger.valueOf(23L); seed = new byte[24]; - // perform test case 1 + // perform test case 1.1 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#1.1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); // test case 2 parameters set, // b is not in field - passed=false; f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.valueOf(19L); b = BigInteger.valueOf(24L); seed = new byte[24]; // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#2: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 3 parameters set, // both a and b are not in field - passed=false; f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.valueOf(25L); b = BigInteger.valueOf(240L); seed = new byte[24]; // perform test case 3 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#3: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -235,53 +219,48 @@ * Expected: must throw IllegalArgumentException */ public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray04() { - boolean passed=false; // test case 1 parameters set, // a is not in field ECFieldF2m f = new ECFieldF2m(5); BigInteger a = BigInteger.valueOf(32L); BigInteger b = BigInteger.valueOf(19L); byte[] seed = new byte[24]; + + // perform test case 1 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 2 parameters set, // b is not in field - passed=false; f = new ECFieldF2m(5); a = BigInteger.valueOf(19L); b = BigInteger.valueOf(32L); seed = new byte[24]; // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#2: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 3 parameters set, // both a and b are not in field - passed=false; f = new ECFieldF2m(5); a = BigInteger.valueOf(32L); b = BigInteger.valueOf(43L); seed = new byte[24]; // perform test case 3 try { - EllipticCurve c = new EllipticCurve(f, a, b, seed); + new EllipticCurve(f, a, b, seed); + fail("#3: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -318,14 +297,14 @@ BigInteger a = BigInteger.ONE; BigInteger b = BigInteger.valueOf(19L); // perform test case 1 - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); // test case 2 parameters set ECFieldF2m f1 = new ECFieldF2m(5); a = BigInteger.ZERO; b = BigInteger.valueOf(23L); // perform test case 2 - c = new EllipticCurve(f1, a, b); + new EllipticCurve(f1, a, b); // test case 3 parameters set, // the seed parameter may be null @@ -333,7 +312,7 @@ a = BigInteger.ONE; b = BigInteger.valueOf(19L); // perform test case 3 - c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); } /** @@ -345,48 +324,41 @@ * Expected: must throw NullPointerException */ public final void testEllipticCurveECFieldBigIntegerBigInteger02() { - boolean passed=false; // test case 1 parameters set ECFieldFp f = null; BigInteger a = BigInteger.ONE; BigInteger b = BigInteger.valueOf(19L); + // perform test case 1 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#1: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); - passed=false; + // test case 2 parameters set, f = new ECFieldFp(BigInteger.valueOf(23L)); a = null; b = BigInteger.valueOf(19L); // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#2: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); // test case 3 parameters set, - passed=false; f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.ONE; b = null; - // perform test case 2 + // perform test case 3 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#3: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -400,65 +372,57 @@ * Expected: must throw IllegalArgumentException */ public final void testEllipticCurveECFieldBigIntegerBigInteger03() { - boolean passed=false; // test case 1 parameters set, // a is not in field ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L)); BigInteger a = BigInteger.valueOf(24L); BigInteger b = BigInteger.valueOf(19L); + // perform test case 1 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); - passed=false; + // test case 1.1 parameters set, // a is not in field f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.valueOf(23L); b = BigInteger.valueOf(19L); - // perform test case 1 + // perform test case 1.1 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#1.1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 2 parameters set, // b is not in field - passed=false; f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.valueOf(19L); b = BigInteger.valueOf(24L); // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#2: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 3 parameters set, // both a and b are not in field - passed=false; f = new ECFieldFp(BigInteger.valueOf(23L)); a = BigInteger.valueOf(25L); b = BigInteger.valueOf(240L); // perform test case 3 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#3: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -472,7 +436,6 @@ * Expected: must throw IllegalArgumentException */ public final void testEllipticCurveECFieldBigIntegerBigInteger04() { - boolean passed=false; // test case 1 parameters set, // a is not in field ECFieldF2m f = new ECFieldF2m(5); @@ -480,42 +443,36 @@ BigInteger b = BigInteger.valueOf(19L); // perform test case 1 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#1: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 2 parameters set, // b is not in field - passed=false; f = new ECFieldF2m(5); a = BigInteger.valueOf(19L); b = BigInteger.valueOf(32L); // perform test case 2 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#2: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // test case 3 parameters set, // both a and b are not in field - passed=false; f = new ECFieldF2m(5); a = BigInteger.valueOf(32L); b = BigInteger.valueOf(43L); // perform test case 3 try { - EllipticCurve c = new EllipticCurve(f, a, b); + new EllipticCurve(f, a, b); + fail("#3: Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed=true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -626,7 +583,7 @@ BigInteger b = BigInteger.valueOf(19L); byte[] seed = new byte[24]; EllipticCurve c = new EllipticCurve(f, a, b, seed); - byte[] seedRet = c.getSeed(); + c.getSeed(); assertNotSame(c.getSeed(), c.getSeed()); } @@ -775,7 +732,6 @@ BigInteger.valueOf(19L), new byte[24]); hc = f.hashCode(); - logln(getName() + ": " + hc); assertTrue(hc == f.hashCode() && hc == f.hashCode() && hc == f.hashCode() && Index: modules/security2/test/common/unit/java/security/spec/ECPublicKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECPublicKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECPublicKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECPublicKeySpec class fields and methods. * */ -public class ECPublicKeySpecTest extends PerformanceTest { +public class ECPublicKeySpecTest extends TestCase { /* * @see TestCase#setUp() @@ -76,9 +76,8 @@ BigInteger.ZERO, BigInteger.valueOf(4L)); ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); - ECPublicKeySpec ks = - new ECPublicKeySpec(g, - new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); + new ECPublicKeySpec(g, + new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); } @@ -98,35 +97,28 @@ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); // Test case 1: w is null - boolean passed = false; try { - ECPublicKeySpec ks = new ECPublicKeySpec(null, + new ECPublicKeySpec(null, new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); + fail("#1: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 2: params is null - passed = false; try { - ECPublicKeySpec ks = new ECPublicKeySpec(g, null); + new ECPublicKeySpec(g, null); + fail("#2: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); + // Test case 3: both w and params are null - passed = false; try { - ECPublicKeySpec ks = new ECPublicKeySpec(null, null); + new ECPublicKeySpec(null, null); + fail("#3: Expected NPE not thrown"); } catch (NullPointerException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** @@ -144,16 +136,13 @@ BigInteger.ZERO, BigInteger.valueOf(4L)); ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L)); - boolean passed = false; + try { - ECPublicKeySpec ks = - new ECPublicKeySpec(ECPoint.POINT_INFINITY, - new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); + new ECPublicKeySpec(ECPoint.POINT_INFINITY, + new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10)); + fail("Expected IAE not thrown"); } catch (IllegalArgumentException ok) { - passed = true; - logln(getName() + ": " + ok); } - assertTrue(passed); } /** Index: modules/security2/test/common/unit/java/security/spec/X509EncodedKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/X509EncodedKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/X509EncodedKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.util.Arrays; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for X509EncodedKeySpec class fields and methods * */ -public class X509EncodedKeySpecTest extends PerformanceTest { +public class X509EncodedKeySpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/RSAPrivateCrtKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/RSAPrivateCrtKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/RSAPrivateCrtKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAPrivateCrtKeySpec class fields and methods * */ -public class RSAPrivateCrtKeySpecTest extends PerformanceTest { +public class RSAPrivateCrtKeySpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/ECFieldFpTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECFieldFpTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECFieldFpTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECFieldFp class fields and methods. * */ -public class ECFieldFpTest extends PerformanceTest { +public class ECFieldFpTest extends TestCase { /** * @see TestCase#setUp() */ @@ -64,7 +64,7 @@ * using valid p (odd prime) */ public final void testECFieldFp01() { - assertTrue(new ECFieldFp(BigInteger.valueOf(23L)) instanceof ECFieldFp); + new ECFieldFp(BigInteger.valueOf(23L)); } /** @@ -74,7 +74,7 @@ * using valid p (odd but not prime) */ public final void testECFieldFp02() { - assertTrue(new ECFieldFp(BigInteger.valueOf(21L)) instanceof ECFieldFp); + new ECFieldFp(BigInteger.valueOf(21L)); } /** @@ -83,20 +83,12 @@ * Assertion: IllegalArgumentException if p is not positive */ public final void testECFieldFp03() { - boolean passed = false; try { - ECFieldFp f = new ECFieldFp(BigInteger.valueOf(-1L)); - loglnError(getName() + + new ECFieldFp(BigInteger.valueOf(-1L)); + fail(getName() + " FAILED: expected exception has not been thrown"); - } catch (Exception e) { - if (e instanceof IllegalArgumentException) { - passed = true; - logln(getName() + ": " + e); - } else { - loglnError(getName() + " FAILED: unexpected exception " + e); - } + } catch (IllegalArgumentException e) { } - assertTrue(passed); } /** @@ -105,20 +97,12 @@ * Assertion: IllegalArgumentException if p is not positive */ public final void testECFieldFp04() { - boolean passed = false; try { - ECFieldFp f = new ECFieldFp(BigInteger.valueOf(0L)); - loglnError(getName() + + new ECFieldFp(BigInteger.valueOf(0L)); + fail(getName() + " FAILED: expected exception has not been thrown"); - } catch (Exception e) { - if (e instanceof IllegalArgumentException) { - passed = true; - logln(getName() + ": " + e); - } else { - loglnError(getName() + " FAILED: unexpected exception " + e); - } + } catch (IllegalArgumentException e) { } - assertTrue(passed); } /** @@ -127,20 +111,12 @@ * Assertion: NullPointerException if p is null */ public final void testECFieldFp05() { - boolean passed = false; try { - ECFieldFp f = new ECFieldFp(null); - loglnError(getName() + + new ECFieldFp(null); + fail(getName() + " FAILED: expected exception has not been thrown"); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } else { - loglnError(getName() + " FAILED: unexpected exception " + e); - } + } catch (NullPointerException e) { } - assertTrue(passed); } /** Index: modules/security2/test/common/unit/java/security/spec/InvalidParameterSpecExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/InvalidParameterSpecExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/InvalidParameterSpecExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.spec.InvalidParameterSpecException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class InvalidParameterSpecExceptionTest extends PerformanceTest { +public class InvalidParameterSpecExceptionTest extends TestCase { public static void main(String[] args) { } @@ -80,7 +80,6 @@ */ public void testInvalidParameterSpecException01() { InvalidParameterSpecException tE = new InvalidParameterSpecException(); - assertTrue(errNotExc, tE instanceof InvalidParameterSpecException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -99,8 +98,6 @@ InvalidParameterSpecException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidParameterSpecException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidParameterSpecException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -121,7 +118,6 @@ String msg = null; InvalidParameterSpecException tE = new InvalidParameterSpecException( msg); - assertTrue(errNotExc, tE instanceof InvalidParameterSpecException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/java/security/spec/PSSParameterSpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/PSSParameterSpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/PSSParameterSpecTest.java (working copy) @@ -21,13 +21,13 @@ package java.security.spec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PSSParameterSpec class (1.5) * */ -public class PSSParameterSpecTest extends PerformanceTest { +public class PSSParameterSpecTest extends TestCase { /* * @see TestCase#setUp() @@ -69,16 +69,11 @@ * if saltLen less than 0 */ public final void testPSSParameterSpec0102() { - boolean passed = false; try { - AlgorithmParameterSpec aps = new PSSParameterSpec(-1); - } catch (Exception e) { - if (e instanceof IllegalArgumentException) { - passed = true; - } - logln(getName() + ": " + e); + new PSSParameterSpec(-1); + fail("Expected IAE not thrown"); + } catch (IllegalArgumentException e) { } - assertTrue(passed); } /** @@ -105,17 +100,11 @@ * if mdName is null */ public final void testPSSParameterSpec0202() { - boolean passed = false; try { - AlgorithmParameterSpec aps = new PSSParameterSpec(null, "MGF1", - MGF1ParameterSpec.SHA1, 20, 1); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - } - logln(getName() + ": " + e); + new PSSParameterSpec(null, "MGF1", MGF1ParameterSpec.SHA1, 20, 1); + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -128,17 +117,11 @@ * if mgfName is null */ public final void testPSSParameterSpec0203() { - boolean passed = false; try { - AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", null, - MGF1ParameterSpec.SHA1, 20, 1); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - } - logln(getName() + ": " + e); + new PSSParameterSpec("SHA-1", null, MGF1ParameterSpec.SHA1, 20, 1); + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -151,17 +134,12 @@ * if saltLen less than 0 */ public final void testPSSParameterSpec0204() { - boolean passed = false; try { - AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1", + new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, -20, 1); - } catch (Exception e) { - if (e instanceof IllegalArgumentException) { - passed = true; - } - logln(getName() + ": " + e); + fail("Expected IAE not thrown"); + } catch (IllegalArgumentException e) { } - assertTrue(passed); } /** @@ -174,17 +152,12 @@ * if trailerField less than 0 */ public final void testPSSParameterSpec0205() { - boolean passed = false; try { - AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1", + new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, -1); - } catch (Exception e) { - if (e instanceof IllegalArgumentException) { - passed = true; - } - logln(getName() + ": " + e); + fail("Expected IAE not thrown"); + } catch (IllegalArgumentException e) { } - assertTrue(passed); } /** @@ -196,15 +169,7 @@ * */ public final void testPSSParameterSpec0206() { - boolean passed = true; - try { - AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1", - null, 20, 1); - } catch (Exception e) { - passed = false; - logln(getName() + ": " + e); - } - assertTrue(passed); + new PSSParameterSpec("SHA-1", "MGF1", null, 20, 1); } /** Index: modules/security2/test/common/unit/java/security/spec/DSAParameterSpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/DSAParameterSpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/DSAParameterSpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DSAParameterSpec * */ -public class DSAParameterSpecTest extends PerformanceTest { +public class DSAParameterSpecTest extends TestCase { /** * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/EncodedKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/EncodedKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/EncodedKeySpecTest.java (working copy) @@ -22,7 +22,7 @@ package java.security.spec; import org.apache.harmony.security.spec.MyEncodedKeySpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -30,7 +30,7 @@ * */ -public class EncodedKeySpecTest extends PerformanceTest { +public class EncodedKeySpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for RSAMultiPrimePrivateCrtKeySpec class fields and methods. * */ -public class RSAMultiPrimePrivateCrtKeySpecTest extends PerformanceTest { +public class RSAMultiPrimePrivateCrtKeySpecTest extends TestCase { /** * Reference array of RSAOtherPrimeInfo. DO NOT MODIFY */ @@ -108,9 +108,8 @@ * Assertion: NullPointerException if modulus is null */ public final void testRSAMultiPrimePrivateCrtKeySpec02() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( null, BigInteger.ONE, BigInteger.ONE, @@ -120,13 +119,9 @@ BigInteger.ONE, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -144,9 +139,8 @@ * Assertion: NullPointerException if publicExponent is null */ public final void testRSAMultiPrimePrivateCrtKeySpec03() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, null, BigInteger.ONE, @@ -156,13 +150,9 @@ BigInteger.ONE, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -180,9 +170,8 @@ * Assertion: NullPointerException if privateExponent is null */ public final void testRSAMultiPrimePrivateCrtKeySpec04() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, null, @@ -192,13 +181,9 @@ BigInteger.ONE, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -216,9 +201,8 @@ * Assertion: NullPointerException if primeP is null */ public final void testRSAMultiPrimePrivateCrtKeySpec05() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, @@ -228,13 +212,9 @@ BigInteger.ONE, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -252,9 +232,8 @@ * Assertion: NullPointerException if primeQ is null */ public final void testRSAMultiPrimePrivateCrtKeySpec06() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, @@ -264,13 +243,9 @@ BigInteger.ONE, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -288,9 +263,8 @@ * Assertion: NullPointerException if primeExponentP is null */ public final void testRSAMultiPrimePrivateCrtKeySpec07() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, @@ -300,13 +274,9 @@ BigInteger.ONE, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -324,9 +294,8 @@ * Assertion: NullPointerException if primeExponentQ is null */ public final void testRSAMultiPrimePrivateCrtKeySpec08() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, @@ -336,13 +305,9 @@ null, BigInteger.ONE, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -360,9 +325,8 @@ * Assertion: NullPointerException if crtCoefficient is null */ public final void testRSAMultiPrimePrivateCrtKeySpec09() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, @@ -372,13 +336,9 @@ BigInteger.ONE, null, opi); - } catch (Exception e) { - if (e instanceof NullPointerException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected NPE not thrown"); + } catch (NullPointerException e) { } - assertTrue(passed); } /** @@ -396,22 +356,16 @@ * Assertion: otherPrimeInfo can be null */ public final void testRSAMultiPrimePrivateCrtKeySpec10() { - boolean passed = false; - try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( - BigInteger.ONE, - BigInteger.ONE, - BigInteger.ONE, - BigInteger.ONE, - BigInteger.ONE, - BigInteger.ONE, - BigInteger.ONE, - BigInteger.ONE, - null); - passed = true; - } catch (Exception e) { - } - assertTrue(passed); + new RSAMultiPrimePrivateCrtKeySpec( + BigInteger.ONE, + BigInteger.ONE, + BigInteger.ONE, + BigInteger.ONE, + BigInteger.ONE, + BigInteger.ONE, + BigInteger.ONE, + BigInteger.ONE, + null); } /** @@ -429,9 +383,8 @@ * Assertion: IllegalArgumentException if otherPrimeInfo length is 0 */ public final void testRSAMultiPrimePrivateCrtKeySpec11() { - boolean passed = false; try { - KeySpec ks = new RSAMultiPrimePrivateCrtKeySpec( + new RSAMultiPrimePrivateCrtKeySpec( BigInteger.ONE, BigInteger.ONE, BigInteger.ONE, @@ -441,13 +394,9 @@ BigInteger.ONE, BigInteger.ONE, new RSAOtherPrimeInfo[0]); - } catch (Exception e) { - if (e instanceof IllegalArgumentException) { - passed = true; - logln(getName() + ": " + e); - } + fail("Expected IAE not thrown"); + } catch (IllegalArgumentException e) { } - assertTrue(passed); } /** Index: modules/security2/test/common/unit/java/security/spec/DSAPrivateKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/DSAPrivateKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/DSAPrivateKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DSAPrivateKeySpec * */ -public class DSAPrivateKeySpecTest extends PerformanceTest { +public class DSAPrivateKeySpecTest extends TestCase { /** * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/InvalidKeySpecExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/InvalidKeySpecExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/InvalidKeySpecExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.spec.InvalidKeySpecException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class InvalidKeySpecExceptionTest extends PerformanceTest { +public class InvalidKeySpecExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testInvalidKeySpecException01() { InvalidKeySpecException tE = new InvalidKeySpecException(); - assertTrue(errNotExc, tE instanceof InvalidKeySpecException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ InvalidKeySpecException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidKeySpecException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidKeySpecException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testInvalidKeySpecException03() { String msg = null; InvalidKeySpecException tE = new InvalidKeySpecException(msg); - assertTrue(errNotExc, tE instanceof InvalidKeySpecException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -137,7 +133,6 @@ public void testInvalidKeySpecException04() { Throwable cause = null; InvalidKeySpecException tE = new InvalidKeySpecException(cause); - assertTrue(errNotExc, tE instanceof InvalidKeySpecException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -154,7 +149,6 @@ */ public void testInvalidKeySpecException05() { InvalidKeySpecException tE = new InvalidKeySpecException(tCause); - assertTrue(errNotExc, tE instanceof InvalidKeySpecException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -178,7 +172,6 @@ */ public void testInvalidKeySpecException06() { InvalidKeySpecException tE = new InvalidKeySpecException(null, null); - assertTrue(errNotExc, tE instanceof InvalidKeySpecException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -197,8 +190,6 @@ InvalidKeySpecException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidKeySpecException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidKeySpecException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -217,7 +208,6 @@ */ public void testInvalidKeySpecException08() { InvalidKeySpecException tE = new InvalidKeySpecException(null, tCause); - assertTrue(errNotExc, tE instanceof InvalidKeySpecException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -243,8 +233,6 @@ InvalidKeySpecException tE; for (int i = 0; i < msgs.length; i++) { tE = new InvalidKeySpecException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof InvalidKeySpecException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/spec/DSAPublicKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/DSAPublicKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/DSAPublicKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.math.BigInteger; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DSAPublicKeySpec * */ -public class DSAPublicKeySpecTest extends PerformanceTest { +public class DSAPublicKeySpecTest extends TestCase { /** * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/ECGenParameterSpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/ECGenParameterSpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/ECGenParameterSpecTest.java (working copy) @@ -21,13 +21,13 @@ package java.security.spec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ECGenParameterSpec class fields and methods. * */ -public class ECGenParameterSpecTest extends PerformanceTest { +public class ECGenParameterSpecTest extends TestCase { /** * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/spec/PKCS8EncodedKeySpecTest.java =================================================================== --- modules/security2/test/common/unit/java/security/spec/PKCS8EncodedKeySpecTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/spec/PKCS8EncodedKeySpecTest.java (working copy) @@ -23,14 +23,14 @@ import java.util.Arrays; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PKCS8EncodedKeySpec class fields and methods. * */ -public class PKCS8EncodedKeySpecTest extends PerformanceTest { +public class PKCS8EncodedKeySpecTest extends TestCase { /* * @see TestCase#setUp() Index: modules/security2/test/common/unit/java/security/PermissionsTest.java =================================================================== --- modules/security2/test/common/unit/java/security/PermissionsTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/PermissionsTest.java (working copy) @@ -27,7 +27,7 @@ import java.util.Enumeration; import java.util.NoSuchElementException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -35,7 +35,7 @@ * */ -public class PermissionsTest extends PerformanceTest { +public class PermissionsTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(PermissionsTest.class); Index: modules/security2/test/common/unit/java/security/KSSecretKeyEntryTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KSSecretKeyEntryTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KSSecretKeyEntryTest.java (working copy) @@ -24,14 +24,14 @@ import javax.crypto.SecretKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for KeyStore.SecretKeyEntry class constructor and methods * */ -public class KSSecretKeyEntryTest extends PerformanceTest { +public class KSSecretKeyEntryTest extends TestCase { /** * Constructor for KSSecretKeyTest. @@ -60,7 +60,6 @@ public void testGetSecretKey() { SecretKey sk = new tmpSecretKey(); KeyStore.SecretKeyEntry ske = new KeyStore.SecretKeyEntry(sk); - assertTrue("Not KeyStore.SecretKeyEntry object", ske instanceof KeyStore.SecretKeyEntry); assertEquals("Incorrect SecretKey", sk, ske.getSecretKey()); } @@ -71,9 +70,7 @@ public void testToString() { SecretKey sk = new tmpSecretKey(); KeyStore.SecretKeyEntry ske = new KeyStore.SecretKeyEntry(sk); - assertTrue("Not KeyStore.SecretKeyEntry object", ske instanceof KeyStore.SecretKeyEntry); assertNotNull("toString() returns null string", ske.toString()); - logln(ske.toString()); } } Index: modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorTest1.java =================================================================== --- modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorTest1.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorTest1.java (working copy) @@ -24,7 +24,7 @@ import java.security.spec.AlgorithmParameterSpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -33,7 +33,7 @@ * */ -public class AlgorithmParameterGeneratorTest1 extends PerformanceTest { +public class AlgorithmParameterGeneratorTest1 extends TestCase { /** * Constructor for AlgorithmParameterGeneratorTests. * @@ -122,8 +122,6 @@ AlgorithmParameterGenerator apg; for (int i = 0; i < algs.length; i++) { apg = AlgorithmParameterGenerator.getInstance(algs[i]); - assertTrue("Not AlgorithmParameterGenerator object", - apg instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", apg.getAlgorithm(), algs[i]); } } @@ -225,8 +223,6 @@ for (int i = 0; i < algs.length; i++) { apg = AlgorithmParameterGenerator.getInstance(algs[i], validProviderName); - assertTrue("Not AlgorithmParameterGenerator object", - apg instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", algs[i], apg.getAlgorithm()); assertEquals("Incorrect provider", apg.getProvider().getName(), validProviderName); @@ -298,8 +294,6 @@ for (int i = 0; i < algs.length; i++) { apg = AlgorithmParameterGenerator.getInstance(algs[i], validProvider); - assertTrue("Not AlgorithmParameterGenerator object", - apg instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", apg.getAlgorithm(), algs[i]); assertEquals("Incorrect provider", apg.getProvider(), validProvider); } @@ -319,8 +313,6 @@ .getInstance(validAlgName); apg.init(512); AlgorithmParameters ap = apg.generateParameters(); - assertTrue("Not AlgorithmParameters object", - ap instanceof AlgorithmParameters); assertEquals("Incorrect algorithm", ap.getAlgorithm().toUpperCase(), apg.getAlgorithm().toUpperCase()); } @@ -330,7 +322,7 @@ * init(int size, SecureRandom random methods * Assertion: throws InvalidParameterExceptiom when size is incorrect */ - public void testAlgorithmParameterGenerator11() { + public void testAlgorithmParameterGenerator11() throws InvalidParameterException { if (!DSASupported) { fail(validAlgName + " algorithm is not supported"); return; @@ -340,35 +332,15 @@ AlgorithmParameterGenerator[] apgs = createAPGen(); assertNotNull("AlgorithmParameterGenerator objects were not created", apgs); + for (int i = 0; i < apgs.length; i++) { for (int j = 0; j < keys.length; j++) { - - try { - apgs[i].init(keys[j]); - logln("Ignore key: " + Integer.toString(keys[j])); - } catch (InvalidParameterException e) { - } - try { - apgs[i].init(keys[j], random); - logln("Ignore key: " + Integer.toString(keys[j])+ " when random is not null"); - } catch (InvalidParameterException e) { - } - try { - apgs[i].init(keys[j], null); - logln("Ignore key: " + Integer.toString(keys[j])+ " when random is null"); - } catch (InvalidParameterException e) { - } + apgs[i].init(keys[j]); + apgs[i].init(keys[j], random); + apgs[i].init(keys[j], null); } - try { - apgs[i].init(1024); - } catch (InvalidParameterException e) { - fail("Unexpected InvalidParameterException was thrown"); - } - try { - apgs[i].init(1024, random); - } catch (InvalidParameterException e) { - fail("Unexpected InvalidParameterException was thrown"); - } + apgs[i].init(1024); + apgs[i].init(1024, random); } } @@ -409,7 +381,6 @@ AlgorithmParameterGeneratorSpi spi = new MyAlgorithmParameterGeneratorSpi(); AlgorithmParameterGenerator apg = new myAlgPG(spi, validProvider, validAlgName); - assertTrue("Not CertStore object", apg instanceof AlgorithmParameterGenerator); assertEquals("Incorrect algorithm", apg.getAlgorithm(), validAlgName); assertEquals("Incorrect provider",apg.getProvider(),validProvider); try { @@ -419,7 +390,6 @@ } apg = new myAlgPG(null, null, null); - assertTrue("Not CertStore object", apg instanceof AlgorithmParameterGenerator); assertNull("Incorrect algorithm", apg.getAlgorithm()); assertNull("Incorrect provider", apg.getProvider()); try { Index: modules/security2/test/common/unit/java/security/SignatureExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/SignatureExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/SignatureExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.SignatureException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SignatureException class constructors and methods. * */ -public class SignatureExceptionTest extends PerformanceTest { +public class SignatureExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testSignatureException01() { SignatureException tE = new SignatureException(); - assertTrue(errNotExc, tE instanceof SignatureException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ SignatureException tE; for (int i = 0; i < msgs.length; i++) { tE = new SignatureException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SignatureException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testSignatureException03() { String msg = null; SignatureException tE = new SignatureException(msg); - assertTrue(errNotExc, tE instanceof SignatureException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -135,7 +131,6 @@ public void testSignatureException04() { Throwable cause = null; SignatureException tE = new SignatureException(cause); - assertTrue(errNotExc, tE instanceof SignatureException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -152,7 +147,6 @@ */ public void testSignatureException05() { SignatureException tE = new SignatureException(tCause); - assertTrue(errNotExc, tE instanceof SignatureException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -176,7 +170,6 @@ */ public void testSignatureException06() { SignatureException tE = new SignatureException(null, null); - assertTrue(errNotExc, tE instanceof SignatureException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -195,8 +188,6 @@ SignatureException tE; for (int i = 0; i < msgs.length; i++) { tE = new SignatureException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SignatureException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -215,7 +206,6 @@ */ public void testSignatureException08() { SignatureException tE = new SignatureException(null, tCause); - assertTrue(errNotExc, tE instanceof SignatureException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -241,8 +231,6 @@ SignatureException tE; for (int i = 0; i < msgs.length; i++) { tE = new SignatureException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SignatureException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/java/security/AccessControlExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/AccessControlExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AccessControlExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Unit test for AccessControlException. */ -public class AccessControlExceptionTest extends PerformanceTest { +public class AccessControlExceptionTest extends TestCase { /** * Entry point for standalone run. Index: modules/security2/test/common/unit/java/security/IdentityScopeTest.java =================================================================== --- modules/security2/test/common/unit/java/security/IdentityScopeTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/IdentityScopeTest.java (working copy) @@ -22,7 +22,7 @@ package java.security; import org.apache.harmony.security.IdentityScopeStub; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -30,7 +30,7 @@ * */ -public class IdentityScopeTest extends PerformanceTest { +public class IdentityScopeTest extends TestCase { public static class MySecurityManager extends SecurityManager { public Permissions denied = new Permissions(); Index: modules/security2/test/common/unit/java/security/KeyStoreTest2.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyStoreTest2.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyStoreTest2.java (working copy) @@ -33,7 +33,7 @@ import org.apache.harmony.security.SpiEngUtils; import org.apache.harmony.security.cert.MyCertificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import java.util.Date; @@ -43,7 +43,7 @@ * */ -public class KeyStoreTest2 extends PerformanceTest { +public class KeyStoreTest2 extends TestCase { private static final String KeyStoreProviderClass = "java.security.MyKeyStoreSpi"; @@ -153,32 +153,29 @@ fail("IOException must be thrown"); } catch (IOException e) { } + KeyStore.LoadStoreParameter lParam = new MyLoadStoreParams( new KeyStore.PasswordProtection(new char[0])); try { keyS.store(null); fail("IOException must be thrown when param is null"); } catch (IOException e) { - } catch (UnsupportedOperationException e) { - logln("store(null) throws UnsupportedOperationException, but expected IOException"); - } catch (IllegalArgumentException e) { - logln("store(null) throws IllegalArgumentException, but expected IOException"); } + try { keyS.load(null); - logln("load(null) does not throw any exception"); + fail("load(null) does not throw any exception"); } catch (IOException e) { } + try { keyS.store(lParam); fail("UnsupportedOperationException must be thrown"); } catch (UnsupportedOperationException e) { } - try { - keyS.load(lParam); - } catch (UnsupportedOperationException e) { - logln("load(LoadSroreParameter) throws UnsupportedOperationException"); - } + + keyS.load(lParam); + assertFalse("Incorrect result of entryInstanceOf", keyS .entryInstanceOf(alias, alias.getClass())); } @@ -216,7 +213,7 @@ } MyCertificate mc = new MyCertificate("type", new byte[0]); try { - keyS.getCertificateAlias((Certificate) mc); + keyS.getCertificateAlias(mc); fail(eMsg); } catch (KeyStoreException e) { } @@ -233,7 +230,7 @@ KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection( new char[0]); try { - keyS.getEntry(alias, (KeyStore.ProtectionParameter) pp); + keyS.getEntry(alias, pp); fail(eMsg); } catch (KeyStoreException e) { } @@ -320,8 +317,6 @@ KeyStore keyS; for (int i = 0; i < validValues.length; i++) { keyS = KeyStore.getInstance(validValues[i]); - assertTrue("Not instanceof KeyStore object", - keyS instanceof KeyStore); assertEquals("Incorrect type", keyS.getType(), validValues[i]); assertEquals("Incorrect provider", keyS.getProvider(), mProv); checkKeyStoreException(keyS); @@ -379,8 +374,6 @@ KeyStore keyS; for (int i = 0; i < validValues.length; i++) { keyS = KeyStore.getInstance(validValues[i], mProv.getName()); - assertTrue("Not instanceof KeyStore object", - keyS instanceof KeyStore); assertEquals("Incorrect type", keyS.getType(), validValues[i]); assertEquals("Incorrect provider", keyS.getProvider().getName(), mProv.getName()); @@ -428,8 +421,6 @@ KeyStore keyS; for (int i = 0; i < validValues.length; i++) { keyS = KeyStore.getInstance(validValues[i], mProv); - assertTrue("Not instanceof KeyStore object", - keyS instanceof KeyStore); assertEquals("Incorrect type", keyS.getType(), validValues[i]); assertEquals("Incorrect provider", keyS.getProvider(), mProv); checkKeyStoreException(keyS); Index: modules/security2/test/common/unit/java/security/PermissionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/PermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/PermissionTest.java (working copy) @@ -21,13 +21,13 @@ package java.security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for Permission */ -public class PermissionTest extends PerformanceTest { +public class PermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(PermissionTest.class); Index: modules/security2/test/common/unit/java/security/KeyTest.java =================================================================== --- modules/security2/test/common/unit/java/security/KeyTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/KeyTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.Key; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * */ -public class KeyTest extends PerformanceTest { +public class KeyTest extends TestCase { /** * Constructor for KeyTest. Index: modules/security2/test/common/unit/java/security/CodeSourceTest.java =================================================================== --- modules/security2/test/common/unit/java/security/CodeSourceTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/CodeSourceTest.java (working copy) @@ -36,7 +36,7 @@ import javax.security.auth.x500.X500Principal; import org.apache.harmony.security.TestCertUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -44,7 +44,7 @@ * */ -public class CodeSourceTest extends PerformanceTest { +public class CodeSourceTest extends TestCase { /** * * Entry point for standalone runs. Index: modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorSpiTests.java =================================================================== --- modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/java/security/AlgorithmParameterGeneratorSpiTests.java (working copy) @@ -24,7 +24,7 @@ import java.security.spec.AlgorithmParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -33,7 +33,7 @@ * */ -public class AlgorithmParameterGeneratorSpiTests extends PerformanceTest { +public class AlgorithmParameterGeneratorSpiTests extends TestCase { /** * Constructor for CertPathBuilderTests. Index: modules/security2/test/common/unit/java/security/DigestExceptionTest.java =================================================================== --- modules/security2/test/common/unit/java/security/DigestExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/java/security/DigestExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import java.security.DigestException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class DigestExceptionTest extends PerformanceTest { +public class DigestExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testDigestException01() { DigestException tE = new DigestException(); - assertTrue(errNotExc, tE instanceof DigestException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ DigestException tE; for (int i = 0; i < msgs.length; i++) { tE = new DigestException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof DigestException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testDigestException03() { String msg = null; DigestException tE = new DigestException(msg); - assertTrue(errNotExc, tE instanceof DigestException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -134,7 +130,6 @@ public void testDigestException04() { Throwable cause = null; DigestException tE = new DigestException(cause); - assertTrue(errNotExc, tE instanceof DigestException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -150,7 +145,6 @@ */ public void testDigestException05() { DigestException tE = new DigestException(tCause); - assertTrue(errNotExc, tE instanceof DigestException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -174,7 +168,6 @@ */ public void testDigestException06() { DigestException tE = new DigestException(null, null); - assertTrue(errNotExc, tE instanceof DigestException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -193,8 +186,6 @@ DigestException tE; for (int i = 0; i < msgs.length; i++) { tE = new DigestException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof DigestException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -213,7 +204,6 @@ */ public void testDigestException08() { DigestException tE = new DigestException(null, tCause); - assertTrue(errNotExc, tE instanceof DigestException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -239,8 +229,6 @@ DigestException tE; for (int i = 0; i < msgs.length; i++) { tE = new DigestException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof DigestException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/org/apache/harmony/security/test/TestUtils.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/test/TestUtils.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/test/TestUtils.java (working copy) @@ -41,7 +41,7 @@ /** * Prints byte array data as hex to the - * PerformanceTest log in the customizable form. + * System.out in the customizable form. * * @param perLine how many numbers put on single line * @param prefix custom output number prefix @@ -57,39 +57,12 @@ if (tail.length() == 1) { tail = "0" + tail; } - PerformanceTest.log(prefix + "0x" + tail + delimiter); - - if (((i+1)%perLine) == 0) { - PerformanceTest.logln(""); - } - } - PerformanceTest.logln(""); - } - - /** - * Prints byte array data as hex to the - * System.out in the customizable form. - * - * @param perLine how many numbers put on single line - * @param prefix custom output number prefix - * @param delimiter custom output number delimiter - * @param data data to be printed - */ - public static void printAsHex1(int perLine, - String prefix, - String delimiter, - byte[] data) { - for (int i=0; i"TEST_SRC_DIR" system property. * */ -public abstract class SerializationTest extends PerformanceTest { +public abstract class SerializationTest extends TestCase { /** + * Property name for the testing mode. + */ + public static final String MODE_KEY = "test.mode"; + + + /** + * Testing mode. + */ + public static String mode = System.getProperty(MODE_KEY); + + /** * Reference files generation mode switch. */ public static final String SERIAL_REFERENCE_MODE = "serial.reference"; Index: modules/security2/test/common/unit/org/apache/harmony/security/SystemScopeTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/SystemScopeTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/SystemScopeTest.java (working copy) @@ -26,7 +26,7 @@ import java.util.Enumeration; import org.apache.harmony.security.SystemScope; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -34,7 +34,7 @@ * */ -public class SystemScopeTest extends PerformanceTest { +public class SystemScopeTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(SystemScopeTest.class); Index: modules/security2/test/common/unit/org/apache/harmony/security/DefaultPolicyScannerTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/DefaultPolicyScannerTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/DefaultPolicyScannerTest.java (working copy) @@ -31,7 +31,7 @@ import java.util.List; import org.apache.harmony.security.DefaultPolicyScanner; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -39,7 +39,7 @@ * */ -public class DefaultPolicyScannerTest extends PerformanceTest { +public class DefaultPolicyScannerTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DefaultPolicyScannerTest.class); Index: modules/security2/test/common/unit/org/apache/harmony/security/PolicyEntryTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/PolicyEntryTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/PolicyEntryTest.java (working copy) @@ -35,7 +35,7 @@ import org.apache.harmony.security.PolicyEntry; import org.apache.harmony.security.UnresolvedPrincipal; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -43,7 +43,7 @@ * */ -public class PolicyEntryTest extends PerformanceTest { +public class PolicyEntryTest extends TestCase { /** * Tests constructor and accessors of PolicyEntry Index: modules/security2/test/common/unit/org/apache/harmony/security/x/crypto/NullCipherSpiTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/x/crypto/NullCipherSpiTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/x/crypto/NullCipherSpiTest.java (working copy) @@ -25,7 +25,7 @@ import javax.crypto.ShortBufferException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.x.crypto.NullCipherSpi; @@ -33,7 +33,7 @@ * * Tests for NullCipher implementation */ -public class NullCipherSpiTest extends PerformanceTest { +public class NullCipherSpiTest extends TestCase { public void testEngineGetBlockSize() { NullCipherSpi spi = new NullCipherSpi(); Index: modules/security2/test/common/unit/org/apache/harmony/security/x/security/auth/login/DefaultConfigParserTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/x/security/auth/login/DefaultConfigParserTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/x/security/auth/login/DefaultConfigParserTest.java (working copy) @@ -34,7 +34,7 @@ import javax.security.auth.login.AppConfigurationEntry; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.x.security.auth.login.DefaultConfigurationParser; import org.apache.harmony.security.x.security.auth.login.DefaultConfigurationParser.InvalidFormatException; @@ -43,7 +43,7 @@ * Tests parser implementation for default configuration. */ -public class DefaultConfigParserTest extends PerformanceTest { +public class DefaultConfigParserTest extends TestCase { static String outputPath = System.getProperty("TEST_SRC_DIR", "test/common/unit"); Index: modules/security2/test/common/unit/org/apache/harmony/security/x/security/auth/login/DefaultConfigurationTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/x/security/auth/login/DefaultConfigurationTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/x/security/auth/login/DefaultConfigurationTest.java (working copy) @@ -33,7 +33,7 @@ import javax.security.auth.AuthPermission; import javax.security.auth.login.AppConfigurationEntry; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.x.security.auth.login.DefaultConfiguration; @@ -41,7 +41,7 @@ * Tests default configuration implementation. */ -public class DefaultConfigurationTest extends PerformanceTest { +public class DefaultConfigurationTest extends TestCase { static String outputPath = System.getProperty("TEST_SRC_DIR", "test/common/unit"); Index: modules/security2/test/common/unit/org/apache/harmony/security/fortress/PolicyUtilsTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/fortress/PolicyUtilsTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/fortress/PolicyUtilsTest.java (working copy) @@ -36,7 +36,7 @@ import java.util.Properties; import org.apache.harmony.security.fortress.PolicyUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -44,7 +44,7 @@ * */ -public class PolicyUtilsTest extends PerformanceTest { +public class PolicyUtilsTest extends TestCase { /** Tests valid expansion of ${key} entries. */ public void testExpand() throws Exception { Index: modules/security2/test/common/unit/org/apache/harmony/security/fortress/DefaultPolicyParserTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/fortress/DefaultPolicyParserTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/fortress/DefaultPolicyParserTest.java (working copy) @@ -33,7 +33,7 @@ import org.apache.harmony.security.PolicyEntry; import org.apache.harmony.security.fortress.DefaultPolicyParser; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -41,7 +41,7 @@ * */ -public class DefaultPolicyParserTest extends PerformanceTest { +public class DefaultPolicyParserTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DefaultPolicyParserTest.class); Index: modules/security2/test/common/unit/org/apache/harmony/security/fortress/ServicesTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/fortress/ServicesTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/fortress/ServicesTest.java (working copy) @@ -24,14 +24,14 @@ import java.security.Provider; import org.apache.harmony.security.fortress.Services; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * * Tests for Services */ -public class ServicesTest extends PerformanceTest { +public class ServicesTest extends TestCase { public void testInitServiceInfo() { Provider p = new MyProvider(); Index: modules/security2/test/common/unit/org/apache/harmony/security/fortress/DefaultPolicyTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/fortress/DefaultPolicyTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/fortress/DefaultPolicyTest.java (working copy) @@ -38,14 +38,14 @@ import org.apache.harmony.security.UnresolvedPrincipal; import org.apache.harmony.security.fortress.DefaultPolicy; import org.apache.harmony.security.fortress.DefaultPolicyParser; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DefaultPolicy * */ -public class DefaultPolicyTest extends PerformanceTest { +public class DefaultPolicyTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DefaultPolicyTest.class); Index: modules/security2/test/common/unit/org/apache/harmony/security/fortress/EngineTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/fortress/EngineTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/fortress/EngineTest.java (working copy) @@ -27,14 +27,14 @@ import org.apache.harmony.security.fortress.Engine; import org.apache.harmony.security.fortress.Services; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * * Tests for Engine */ -public class EngineTest extends PerformanceTest { +public class EngineTest extends TestCase { protected void tearDown() throws Exception { super.tearDown(); Index: modules/security2/test/common/unit/org/apache/harmony/security/UnresolvedPrincipalTest.java =================================================================== --- modules/security2/test/common/unit/org/apache/harmony/security/UnresolvedPrincipalTest.java (revision 373503) +++ modules/security2/test/common/unit/org/apache/harmony/security/UnresolvedPrincipalTest.java (working copy) @@ -23,7 +23,7 @@ import java.security.Principal; import org.apache.harmony.security.UnresolvedPrincipal; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * */ -public class UnresolvedPrincipalTest extends PerformanceTest { +public class UnresolvedPrincipalTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(UnresolvedPrincipalTest.class); Index: modules/security2/test/common/unit/org/ietf/jgss/GSSManagerTest.java =================================================================== --- modules/security2/test/common/unit/org/ietf/jgss/GSSManagerTest.java (revision 373503) +++ modules/security2/test/common/unit/org/ietf/jgss/GSSManagerTest.java (working copy) @@ -24,13 +24,13 @@ import java.security.Provider; import java.security.Security; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests GSSManager class */ -public class GSSManagerTest extends PerformanceTest { +public class GSSManagerTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(GSSManagerTest.class); Index: modules/security2/test/common/unit/javax/crypto/KeyAgreementTest1.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/KeyAgreementTest1.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/KeyAgreementTest1.java (working copy) @@ -38,7 +38,7 @@ import org.apache.harmony.security.SpiEngUtils; import org.apache.harmony.security.TestKeyPair; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -46,7 +46,7 @@ * */ -public class KeyAgreementTest1 extends PerformanceTest { +public class KeyAgreementTest1 extends TestCase { /** * Constructor for KeyAgreementTest1. @@ -87,40 +87,27 @@ defaultProviderName = (DEFSupported ? defaultProvider.getName() : null); } - private boolean createKeys() { - if (initKeys) { - return true; - } - try { + private void createKeys() throws Exception { + if (!initKeys) { TestKeyPair tkp = new TestKeyPair(defaultAlgorithm); privKey = tkp.getPrivate(); publKey = tkp.getPublic(); initKeys = true; - return true; - } catch (Exception e) { - logln("Unexpected: " + e.toString()); - initKeys = false; - return false; } } - private KeyAgreement[] createKAs() { + private KeyAgreement[] createKAs() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); - return null; } - try { - KeyAgreement[] ka = new KeyAgreement[3]; - ka[0] = KeyAgreement.getInstance(defaultAlgorithm); - ka[1] = KeyAgreement.getInstance(defaultAlgorithm, defaultProvider); - ka[2] = KeyAgreement.getInstance(defaultAlgorithm, - defaultProviderName); - return ka; - } catch (Exception e) { - logln(e.toString()); - return null; - } + + KeyAgreement[] ka = new KeyAgreement[3]; + ka[0] = KeyAgreement.getInstance(defaultAlgorithm); + ka[1] = KeyAgreement.getInstance(defaultAlgorithm, defaultProvider); + ka[2] = KeyAgreement.getInstance(defaultAlgorithm, + defaultProviderName); + return ka; } public static String getDefAlg() { @@ -140,7 +127,6 @@ KeyAgreementSpi spi = new MyKeyAgreementSpi(); KeyAgreement keyA = new myKeyAgreement(spi, defaultProvider, defaultAlgorithm); - assertTrue("Not KeyAgreement object", keyA instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyA.getAlgorithm(), defaultAlgorithm); assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider); @@ -148,7 +134,6 @@ assertEquals("Incorrect result", keyA.generateSecret().length, 0); keyA = new myKeyAgreement(null, null, null); - assertTrue("Not KeyAgreement object", keyA instanceof KeyAgreement); assertNull("Algorithm must be null", keyA.getAlgorithm()); assertNull("Provider must be null", keyA.getProvider()); try { @@ -191,7 +176,6 @@ KeyAgreement keyA; for (int i = 0; i < validValues.length; i++) { keyA = KeyAgreement.getInstance(validValues[i]); - assertTrue("Not KeyAgreement object", keyA instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyA.getAlgorithm(), validValues[i]); } @@ -276,7 +260,6 @@ for (int i = 0; i < validValues.length; i++) { keyA = KeyAgreement .getInstance(validValues[i], defaultProviderName); - assertTrue("Not KeyAgreement object", keyA instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyA.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyA.getProvider().getName(), @@ -343,7 +326,6 @@ KeyAgreement keyA; for (int i = 0; i < validValues.length; i++) { keyA = KeyAgreement.getInstance(validValues[i], defaultProvider); - assertTrue("Not KeyAgreement object", keyA instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyA.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyA.getProvider(), @@ -360,18 +342,16 @@ * sharedsecret in buffer and return numbers of bytes; returns SecretKey * object */ - public void testGenerateSecret03() throws ShortBufferException, - InvalidKeyException, NoSuchAlgorithmException { + public void testGenerateSecret03() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; } - assertTrue("Keys were not created", createKeys()); + createKeys(); KeyAgreement[] kAgs = createKAs(); - assertNotNull("KeyAgreement objects were not created", kAgs); + byte[] bb; byte[] bb1 = new byte[10]; - int t; for (int i = 0; i < kAgs.length; i++) { kAgs[i].init(privKey); kAgs[i].doPhase(publKey, true); @@ -379,11 +359,10 @@ kAgs[i].init(privKey); kAgs[i].doPhase(publKey, true); bb1 = new byte[bb.length + 10]; - t = kAgs[i].generateSecret(bb1, 9); + kAgs[i].generateSecret(bb1, 9); kAgs[i].init(privKey); kAgs[i].doPhase(publKey, true); - assertTrue("Not SecretKey object", - kAgs[i].generateSecret("DES") instanceof SecretKey); + kAgs[i].generateSecret("DES"); } } @@ -391,15 +370,14 @@ * Test for doPhase(Key key, boolean lastPhase) method * Assertion: throws InvalidKeyException if key is not appropriate */ - public void testDoPhase() throws ShortBufferException, InvalidKeyException, - NoSuchAlgorithmException { + public void testDoPhase() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; } - assertTrue("Keys were not created", createKeys()); + createKeys(); KeyAgreement[] kAgs = createKAs(); - assertNotNull("KeyAgreement objects were not created", kAgs); + for (int i = 0; i < kAgs.length; i++) { kAgs[i].init(privKey); try { @@ -423,15 +401,14 @@ * init(Key key, AlgorithmParameterSpec params, SecureRandom random) * Assertion: throws InvalidKeyException when key is inapporopriate */ - public void testInit01() throws InvalidAlgorithmParameterException, - InvalidKeyException { + public void testInit01() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; } - assertTrue("Keys were not created", createKeys()); + createKeys(); KeyAgreement[] kAgs = createKAs(); - assertNotNull("KeyAgreement objects were not created", kAgs); + SecureRandom random = null; AlgorithmParameterSpec aps = null; DHParameterSpec dhPs = new DHParameterSpec(new BigInteger("56"), @@ -477,16 +454,15 @@ * Assertion: throws AlgorithmParameterException when params are * inapporopriate */ - public void testInit02() throws InvalidKeyException { + public void testInit02() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; } - assertTrue("Keys were not created", createKeys()); + createKeys(); KeyAgreement[] kAgs = createKAs(); - assertNotNull("KeyAgreement objects were not created", kAgs); + SecureRandom random = null; - AlgorithmParameterSpec aps = null; DSAParameterSpec dsa = new DSAParameterSpec(new BigInteger("56"), new BigInteger("56"), new BigInteger("56")); for (int i = 0; i < kAgs.length; i++) { @@ -518,19 +494,17 @@ * generateSecret() * Assertions: initializes KeyAgreement and returns byte array */ - public void testInit03() throws InvalidKeyException { + public void testInit03() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; } - assertTrue("Keys were not created", createKeys()); + createKeys(); KeyAgreement[] kAgs = createKAs(); - assertNotNull("KeyAgreement objects were not created", kAgs); + byte[] bbRes1; byte[] bbRes2; byte[] bbRes3; - byte[] bb1 = new byte[10]; - int t; SecureRandom randomNull = null; SecureRandom random = new SecureRandom(); for (int i = 0; i < kAgs.length; i++) { @@ -565,22 +539,20 @@ * generateSecret() * Assertions: initializes KeyAgreement and returns byte array */ - public void testInit04() throws InvalidKeyException, + public void testInit04() throws Exception, InvalidAlgorithmParameterException { if (!DEFSupported) { fail(NotSupportMsg); return; } - assertTrue("Keys were not created", createKeys()); + createKeys(); KeyAgreement[] kAgs = createKAs(); - assertNotNull("KeyAgreement objects were not created", kAgs); + DHParameterSpec dhPs = ((DHPrivateKey) privKey).getParams(); byte[] bbRes1; byte[] bbRes2; byte[] bbRes3; - byte[] bb1 = new byte[10]; - int t; SecureRandom randomNull = null; SecureRandom random = new SecureRandom(); for (int i = 0; i < kAgs.length; i++) { Index: modules/security2/test/common/unit/javax/crypto/interfaces/DHPrivateKeyTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/interfaces/DHPrivateKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/interfaces/DHPrivateKeyTest.java (working copy) @@ -24,7 +24,7 @@ import javax.crypto.interfaces.DHPrivateKey; import javax.crypto.spec.DHParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import java.math.BigInteger; @@ -33,7 +33,7 @@ * Tests for DHPrivateKey class field * */ -public class DHPrivateKeyTest extends PerformanceTest { +public class DHPrivateKeyTest extends TestCase { /** * Constructor for DHPrivateKey. Index: modules/security2/test/common/unit/javax/crypto/interfaces/PBEKeyTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/interfaces/PBEKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/interfaces/PBEKeyTest.java (working copy) @@ -25,14 +25,14 @@ import javax.crypto.interfaces.PBEKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for PBEKey class field * */ -public class PBEKeyTest extends PerformanceTest { +public class PBEKeyTest extends TestCase { /** Index: modules/security2/test/common/unit/javax/crypto/interfaces/DHPublicKeyTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/interfaces/DHPublicKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/interfaces/DHPublicKeyTest.java (working copy) @@ -26,14 +26,14 @@ import javax.crypto.interfaces.DHPublicKey; import javax.crypto.spec.DHParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DHPublicKey class field * */ -public class DHPublicKeyTest extends PerformanceTest { +public class DHPublicKeyTest extends TestCase { public static void main(String[] args) { } Index: modules/security2/test/common/unit/javax/crypto/NullCipherTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/NullCipherTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/NullCipherTest.java (working copy) @@ -23,7 +23,7 @@ import javax.crypto.spec.SecretKeySpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import java.security.*; @@ -31,7 +31,7 @@ * * Tests for NullCipher */ -public class NullCipherTest extends PerformanceTest { +public class NullCipherTest extends TestCase { private Cipher c; Index: modules/security2/test/common/unit/javax/crypto/NoSuchPaddingExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/NoSuchPaddingExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/NoSuchPaddingExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import javax.crypto.NoSuchPaddingException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class NoSuchPaddingExceptionTest extends PerformanceTest { +public class NoSuchPaddingExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testNoSuchPaddingException01() { NoSuchPaddingException tE = new NoSuchPaddingException(); - assertTrue(errNotExc, tE instanceof NoSuchPaddingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ NoSuchPaddingException tE; for (int i = 0; i < msgs.length; i++) { tE = new NoSuchPaddingException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof NoSuchPaddingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testNoSuchPaddingException03() { String msg = null; NoSuchPaddingException tE = new NoSuchPaddingException(msg); - assertTrue(errNotExc, tE instanceof NoSuchPaddingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/crypto/SecretKeyFactoryTest1.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/SecretKeyFactoryTest1.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/SecretKeyFactoryTest1.java (working copy) @@ -33,7 +33,7 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -41,7 +41,7 @@ * */ -public class SecretKeyFactoryTest1 extends PerformanceTest { +public class SecretKeyFactoryTest1 extends TestCase { public static final String srvSecretKeyFactory = "SecretKeyFactory"; Index: modules/security2/test/common/unit/javax/crypto/CipherSpiTests.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/CipherSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/CipherSpiTests.java (working copy) @@ -30,7 +30,7 @@ import java.security.AlgorithmParameters; import java.nio.ByteBuffer; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -38,7 +38,7 @@ * */ -public class CipherSpiTests extends PerformanceTest { +public class CipherSpiTests extends TestCase { /** * Constructor for CipherSpiTests. Index: modules/security2/test/common/unit/javax/crypto/ExemptionMechanismExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/ExemptionMechanismExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/ExemptionMechanismExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import javax.crypto.ExemptionMechanismException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class ExemptionMechanismExceptionTest extends PerformanceTest { +public class ExemptionMechanismExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testExemptionMechanismException01() { ExemptionMechanismException tE = new ExemptionMechanismException(); - assertTrue(errNotExc, tE instanceof ExemptionMechanismException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ ExemptionMechanismException tE; for (int i = 0; i < msgs.length; i++) { tE = new ExemptionMechanismException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof ExemptionMechanismException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testExemptionMechanismException03() { String msg = null; ExemptionMechanismException tE = new ExemptionMechanismException(msg); - assertTrue(errNotExc, tE instanceof ExemptionMechanismException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/crypto/EncryptedPrivateKeyInfoTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/EncryptedPrivateKeyInfoTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/EncryptedPrivateKeyInfoTest.java (working copy) @@ -29,7 +29,6 @@ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.Provider; import java.security.Security; import java.security.spec.InvalidKeySpecException; @@ -41,7 +40,7 @@ import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -52,7 +51,7 @@ * security providers list extended by Bouncy Castle's one * (http://www.bouncycastle.org) */ -public class EncryptedPrivateKeyInfoTest extends PerformanceTest { +public class EncryptedPrivateKeyInfoTest extends TestCase { /** * "valid" encoding for DSA with alg params @@ -1195,7 +1194,7 @@ {"1.2.840.113549.1.3.1", "DiffieHellman"}, {"1.2.840.113549.1.5.3", "pbeWithMD5AndDES-CBC"}, {"1.2.840.113549.1.12.1.3", "pbeWithSHAAnd3-KeyTripleDES-CBC"}, - {"1.2.840.113549.1.12.1.6", "pbeWithSHAAnd40BitRC2-CBC"}, +// {"1.2.840.113549.1.12.1.6", "pbeWithSHAAnd40BitRC2-CBC"}, {"1.2.840.113549.3.2", "RC2-CBC"}, {"1.2.840.113549.3.3", "RC2-EBC"}, {"1.2.840.113549.3.4", "RC4"}, @@ -1362,19 +1361,9 @@ * @throws IOException * @throws NoSuchAlgorithmException */ - public final void testEncryptedPrivateKeyInfobyteArray1() - throws NoSuchAlgorithmException, IOException { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - getValidEncryptedPrivateKeyInfoEncoding("DH")); - logln(getName() + ": ok"); -// for (int i = 0; i < algName0.length; i++) { -// try { -// EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( -// getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0])); -// } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); -// } -// } + public final void testEncryptedPrivateKeyInfobyteArray1() throws Exception { + new EncryptedPrivateKeyInfo(getValidEncryptedPrivateKeyInfoEncoding("DH")); + } /** @@ -1390,10 +1379,9 @@ public final void testEncryptedPrivateKeyInfobyteArray2() throws IOException { try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(null); + new EncryptedPrivateKeyInfo(null); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } } @@ -1406,11 +1394,9 @@ */ public final void testEncryptedPrivateKeyInfobyteArray3() { try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - new byte[0]); + new EncryptedPrivateKeyInfo(new byte[0]); fail(getName() + ": IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); } } @@ -1423,11 +1409,10 @@ */ public final void testEncryptedPrivateKeyInfobyteArray4() { try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( + new EncryptedPrivateKeyInfo( new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); fail(getName() + ": IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); } } @@ -1438,19 +1423,18 @@ * Test preconditions: wrong encoding passed as a parameter
* Expected: IOException */ - public final void testEncryptedPrivateKeyInfobyteArray5() { + public final void testEncryptedPrivateKeyInfobyteArray5() throws Exception { byte[] enc = null; try { // 1: get valid encoding enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + // ... and corrupt it (set wrong alg OID length) enc[9] = (byte) 6; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); + + new EncryptedPrivateKeyInfo(enc); fail(getName() + "(1): IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); } try { @@ -1458,12 +1442,9 @@ enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong encrypted data tag) enc[307] = (byte) 6; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); + new EncryptedPrivateKeyInfo(enc); fail(getName() + "(2): IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); } try { @@ -1471,12 +1452,9 @@ enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong encrypted data length) enc[310] = (byte) 1; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); + new EncryptedPrivateKeyInfo(enc); fail(getName() + "(3): IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); } try { @@ -1492,15 +1470,11 @@ // initialization BUT No AlgorithmParameters instance // available for algName0[i][0]. // So just skip this sub test - // loglnError(getName() + "(4): SKIPPED LEGITIMATELY"); } else { fail(getName() + "(4): IOException has not been thrown"); } } catch (IOException ok) { - logln(getName() + ": " + ok); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); } try { @@ -1508,12 +1482,9 @@ enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong length for alg params sequence) enc[20] = (byte) 0x1d; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); + new EncryptedPrivateKeyInfo(enc); fail(getName() + "(5): IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); } try { @@ -1521,12 +1492,9 @@ enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong length for alg params sequence) enc[20] = (byte) 0x1f; - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); + new EncryptedPrivateKeyInfo(enc); fail(getName() + "(6): IOException has not been thrown"); } catch (IOException ok) { - logln(getName() + ": " + ok); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); } } @@ -1540,21 +1508,16 @@ * * @throws IOException */ - public final void testEncryptedPrivateKeyInfobyteArray6() - throws IOException { - try { - byte[] encoded = getValidEncryptedPrivateKeyInfoEncoding("DSA"); - byte[] encodedCopy = (byte[]) encoded.clone(); - // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - encodedCopy); - // modify array passed - encodedCopy[9] = (byte) 6; - // check that internal state has not been affected - assertTrue(Arrays.equals(encoded, epki.getEncoded())); - } catch (NoSuchAlgorithmException allowedFailure) { - // loglnError(getName() + ": " + allowedFailure); - } + public final void testEncryptedPrivateKeyInfobyteArray6() throws Exception { + byte[] encoded = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + byte[] encodedCopy = (byte[]) encoded.clone(); + // pass valid array + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( + encodedCopy); + // modify array passed + encodedCopy[9] = (byte) 6; + // check that internal state has not been affected + assertTrue(Arrays.equals(encoded, epki.getEncoded())); } /** @@ -1566,15 +1529,16 @@ */ public final void testEncryptedPrivateKeyInfoStringbyteArray1() { boolean performed = false; + for (int i = 0; i < algName0.length; i++) { try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( + new EncryptedPrivateKeyInfo( algName0[i][0], encryptedData); performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); + } catch (NoSuchAlgorithmException allowed) { } } + assertTrue("Test not perfrormed", performed); } @@ -1588,18 +1552,15 @@ */ public final void testEncryptedPrivateKeyInfoStringbyteArray2() { try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - "bla-bla", encryptedData); + new EncryptedPrivateKeyInfo("bla-bla", encryptedData); fail(getName() + ": NoSuchAlgorithmException has not been thrown"); } catch (NoSuchAlgorithmException ok) { - logln(getName() + ": " + ok); } + try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("", - encryptedData); + new EncryptedPrivateKeyInfo("", encryptedData); fail(getName() + ": NoSuchAlgorithmException has not been thrown"); } catch (NoSuchAlgorithmException ok) { - logln(getName() + ": " + ok); } } @@ -1618,22 +1579,17 @@ throws NoSuchAlgorithmException { // pass null as name try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - (String) null, encryptedData); + new EncryptedPrivateKeyInfo((String) null, encryptedData); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } // pass null as encrypted data try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA", - null); + new EncryptedPrivateKeyInfo("DSA", null); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + ": " + allowedFailure); } } @@ -1648,13 +1604,11 @@ */ public final void testEncryptedPrivateKeyInfoStringbyteArray4() { try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA", + new EncryptedPrivateKeyInfo("DSA", new byte[] {}); fail(getName() + ": IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + " " + allowedFailure); } } @@ -1680,7 +1634,6 @@ // check that internal state has not been affected assertTrue(Arrays.equals(encryptedData, epki.getEncryptedData())); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + " " + allowedFailure); } } @@ -1707,12 +1660,10 @@ // use pregenerated AlgorithmParameters encodings ap.init(getParametersEncoding(algName0[i][0])); - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedData); + new EncryptedPrivateKeyInfo(ap, encryptedData); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -1736,23 +1687,20 @@ throws NoSuchAlgorithmException, IOException { // 1: pass null as AlgorithmParameters try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - (AlgorithmParameters) null, encryptedData); + new EncryptedPrivateKeyInfo((AlgorithmParameters) null, encryptedData); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } + // 2: pass null as encrypted data try { AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); // use pregenerated AlgorithmParameters encodings ap.init(getParametersEncoding("DSA")); - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, null); + new EncryptedPrivateKeyInfo(ap, null); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + " " + allowedFailure); } } @@ -1777,14 +1725,11 @@ // use pregenerated AlgorithmParameters encodings ap.init(getParametersEncoding("DSA")); - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - new byte[] {}); + new EncryptedPrivateKeyInfo(ap, new byte[] {}); fail(getName() + ": IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - logln(getName() + ": " + ok); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + " " + allowedFailure); } } @@ -1820,7 +1765,6 @@ assertTrue(Arrays.equals(encryptedData, epki.getEncryptedData())); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + " " + allowedFailure); } } @@ -1841,23 +1785,13 @@ EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0])); - logln(getName() + ": " + algName0[i][0] + - ", expected: " + algName0[i][1] + - ", got: " + epki.getAlgName()); -// if (epki.getAlgParameters() == null) { -// // no AlgorithmParameters instance -// // available for algName0[i][0] so -// // perform another test: -// // epki.getAlgName() must return OID -// // from encoding -// assertTrue("isOID", epki.getAlgName().indexOf('.') != -1); -// } else { -// assertEquals("StdName", algName0[i][1], epki.getAlgName()); -// } +// logln(getName() + ": " + algName0[i][0] + +// ", expected: " + algName0[i][1] + +// ", got: " + epki.getAlgName()); + assertEquals(algName0[i][1], epki.getAlgName()); performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); + } catch (NoSuchAlgorithmException allowed) { } } assertTrue("Test not perfrormed", performed); @@ -1879,14 +1813,13 @@ EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( algName0[i][0], encryptedData); - logln(getName() + ": " + algName0[i][0] + - ", expected: " + algName0[i][1] + - ", got: " + epki.getAlgName()); -// assertEquals(algName0[i][1], epki.getAlgName()); +// logln(getName() + ": " + algName0[i][0] + +// ", expected: " + algName0[i][1] + +// ", got: " + epki.getAlgName()); + assertEquals(algName0[i][1], epki.getAlgName()); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -1913,14 +1846,13 @@ EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, encryptedData); - logln(getName() + ": " + algName0[i][0] + - ", expected: " + algName0[i][1] + - ", got: " + epki.getAlgName()); -// assertEquals(algName0[i][1], epki.getAlgName()); +// logln(getName() + ": " + algName0[i][0] + +// ", expected: " + algName0[i][1] + +// ", got: " + epki.getAlgName()); + assertEquals(algName0[i][1], epki.getAlgName()); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -1945,19 +1877,15 @@ AlgorithmParameters apar = epki.getAlgParameters(); if (apar == null) { -// loglnError(getName() + " NOT PERFORMED: " + -// "No AlgorithmParameters for algorithm " + -// algName0[i][0] + " available"); continue; } + // check that method under test returns // parameters with the same encoded form assertTrue(Arrays.equals(getParametersEncoding(algName0[i][0]), apar.getEncoded())); performed = true; - logln(getName() + ": passed for " + algName0[i][0]); } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -1975,7 +1903,6 @@ assertNull(epki.getAlgParameters()); } catch (NoSuchAlgorithmException allowedFailure) { - // was: loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); fail(getName() + " " + allowedFailure); } } @@ -2003,7 +1930,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2035,7 +1961,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2069,7 +1994,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2099,7 +2023,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2126,7 +2049,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2160,7 +2082,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2191,7 +2112,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2219,7 +2139,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2252,7 +2171,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2287,7 +2205,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2321,7 +2238,6 @@ performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2341,14 +2257,12 @@ fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } catch (InvalidKeySpecException e) { fail(getName() + "Unexpected exception: " + e); } performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2358,10 +2272,8 @@ * Encrypted data contains valid PKCS8 key info encoding */ public final void test_ROUNDTRIP_GetKeySpecCipher01() { - boolean failed = false; - String failedForAlgs = "Failed for:\n"; - String passedForAlgs = "\nPassed for:\n"; boolean performed = false; + for (int i = 0; i < algName.length; i++) { try { // generate test data @@ -2376,42 +2288,31 @@ } else { epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); } + // call methods under test try { PKCS8EncodedKeySpec eks = epki.getKeySpec(g.c()); - if (Arrays.equals(privateKeyInfo, eks.getEncoded())) { - passedForAlgs += algName[i][0] + ", " + algName[i][1] + "\n"; - } else { - failed = true; - failedForAlgs += algName[i][0] + ", " + algName[i][1] + - ": comparison\n"; + if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { + fail(algName[i][0] + " != " + algName[i][1]); } } catch (InvalidKeySpecException e) { - failed = true; - failedForAlgs += algName[i][0] + ", " + algName[i][1] + - ": " + e + "\n"; + fail(algName[i][0] + ", " + algName[i][1] + e + "\n"); } performed = true; + } catch (TestDataGenerator.AllowedFailure allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); - } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); + } catch (NoSuchAlgorithmException allowed) { } } - assertFalse(failedForAlgs+passedForAlgs, failed); assertTrue("Test not perfrormed", performed); - logln(getName() + passedForAlgs); } /** * Encrypted data contains invalid PKCS8 key info encoding */ public final void test_ROUNDTRIP_GetKeySpecCipher02() { - boolean failed = false; - String failedForAlgs = "Failed for:\n"; - String passedForAlgs = "\nPassed for:\n"; boolean performed = false; for (int i = 0; i < algName.length; i++) { try { @@ -2427,28 +2328,23 @@ } else { epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); } + // call methods under test try { + epki.getKeySpec(g.c()); - PKCS8EncodedKeySpec eks = epki.getKeySpec(g.c()); // must not get here because decrypted data does // not represent valid PKCS8 encoding - failed = true; - failedForAlgs += algName[i][0] + ", " + algName[i][1] + "\n"; + fail(algName[i][0] + ", " + algName[i][1]); } catch (InvalidKeySpecException ok) { - passedForAlgs += algName[i][0] + ", " + algName[i][1] + "\n"; } performed = true; } catch (TestDataGenerator.AllowedFailure allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } - assertFalse(failedForAlgs+passedForAlgs, failed); assertTrue("Test not perfrormed", performed); - logln(getName() + passedForAlgs); } public final void testGetKeySpecKey01() { @@ -2465,14 +2361,12 @@ fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); } catch (InvalidKeyException e) { fail(getName() + "Unexpected exception: " + e); } performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2482,9 +2376,6 @@ * Encrypted data contains valid PKCS8 key info encoding */ public final void test_ROUNDTRIP_GetKeySpecKey01() { - boolean failed = false; - String failedForAlgs = "Failed for:\n"; - String passedForAlgs = "\nPassed for:\n"; boolean performed = false; for (int i = 0; i < algName.length; i++) { try { @@ -2505,38 +2396,25 @@ PKCS8EncodedKeySpec eks = epki.getKeySpec(g.pubK()==null ? g.k() : g.pubK()); - if (Arrays.equals(privateKeyInfo, eks.getEncoded())) { - passedForAlgs += algName[i][0] + ", " + algName[i][1] + "\n"; - } else { - failed = true; - failedForAlgs += algName[i][0] + ", " + algName[i][1] + - ": comparison\n"; + if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { + fail(algName[i][0] + " != " + algName[i][1]); } } catch (InvalidKeyException e) { - failed = true; - failedForAlgs += algName[i][0] + ", " + algName[i][1] + - ": " + e + "\n"; + fail(algName[i][0] + ", " + algName[i][1] + ": " + e); } performed = true; } catch (TestDataGenerator.AllowedFailure allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } - assertFalse(failedForAlgs+passedForAlgs, failed); assertTrue("Test not perfrormed", performed); - logln(getName() + passedForAlgs); } /** * Encrypted data contains invalid PKCS8 key info encoding */ public final void test_ROUNDTRIP_GetKeySpecKey02() { - boolean failed = false; - String failedForAlgs = "Failed for:\n"; - String passedForAlgs = "\nPassed for:\n"; boolean performed = false; for (int i = 0; i < algName.length; i++) { try { @@ -2554,29 +2432,20 @@ } try { - PKCS8EncodedKeySpec eks = - epki.getKeySpec(g.pubK()==null ? g.k() : g.pubK()); - - failed = true; - failedForAlgs += algName[i][0] + ", " + algName[i][1] + "\n"; - + epki.getKeySpec(g.pubK()==null ? g.k() : g.pubK()); + fail(algName[i][0] + ", " + algName[i][1]); } catch (InvalidKeyException e) { - passedForAlgs += algName[i][0] + ", " + algName[i][1] + "\n"; } performed = true; } catch (TestDataGenerator.AllowedFailure allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } - assertFalse(failedForAlgs+passedForAlgs, failed); assertTrue("Test not perfrormed", performed); - logln(getName() + passedForAlgs); } - public final void testGetKeySpecKeyString01() { + public final void testGetKeySpecKeyString01() throws Exception { boolean performed = false; for (int i = 0; i < algName0.length; i++) { try { @@ -2590,11 +2459,6 @@ fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); - } catch (InvalidKeyException e) { - fail(getName() + "Unexpected exception: " + e); - } catch (NoSuchProviderException e) { - fail(getName() + "Unexpected exception: " + e); } try { @@ -2617,16 +2481,10 @@ fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { - logln(getName() + ": " + ok); - } catch (InvalidKeyException e) { - fail(getName() + "Unexpected exception: " + e); - } catch (NoSuchProviderException e) { - fail(getName() + "Unexpected exception: " + e); } performed = true; } catch (NoSuchAlgorithmException allowedFailure) { -// loglnError(getName() + " ALLOWED FAILURE: " + allowedFailure); } } assertTrue("Test not perfrormed", performed); @@ -2635,10 +2493,7 @@ /** * Encrypted data contains valid PKCS8 key info encoding */ - public final void test_ROUNDTRIP_GetKeySpecKeyString01() { - boolean failed = false; - String failedForAlgs = "Failed for:\n"; - String passedForAlgs = "\nPassed for:\n"; + public final void test_ROUNDTRIP_GetKeySpecKeyString01() throws Exception { boolean performed = false; for (int i = 0; i < algName.length; i++) { for (int l=0; lKeyGeneratorSpi
class constructors and methods. * */ -public class KeyGeneratorSpiTests extends PerformanceTest { +public class KeyGeneratorSpiTests extends TestCase { /** * Constructor for KeyGeneratorSpiTests. Index: modules/security2/test/common/unit/javax/crypto/IllegalBlockSizeExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/IllegalBlockSizeExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/IllegalBlockSizeExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import javax.crypto.IllegalBlockSizeException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class IllegalBlockSizeExceptionTest extends PerformanceTest { +public class IllegalBlockSizeExceptionTest extends TestCase { public static void main(String[] args) { } @@ -79,7 +79,6 @@ */ public void testIllegalBlockSizeException01() { IllegalBlockSizeException tE = new IllegalBlockSizeException(); - assertTrue(errNotExc, tE instanceof IllegalBlockSizeException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -98,8 +97,6 @@ IllegalBlockSizeException tE; for (int i = 0; i < msgs.length; i++) { tE = new IllegalBlockSizeException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof IllegalBlockSizeException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -119,7 +116,6 @@ public void testIllegalBlockSizeException03() { String msg = null; IllegalBlockSizeException tE = new IllegalBlockSizeException(msg); - assertTrue(errNotExc, tE instanceof IllegalBlockSizeException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/crypto/MacSpiTests.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/MacSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/MacSpiTests.java (working copy) @@ -30,7 +30,7 @@ import javax.crypto.spec.SecretKeySpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -38,7 +38,7 @@ * */ -public class MacSpiTests extends PerformanceTest { +public class MacSpiTests extends TestCase { /** * Constructor for MacSpiTests. @@ -53,14 +53,12 @@ * Test for MacSpi constructor * Assertion: constructs MacSpi */ - public void testMacSpiTests01() throws CloneNotSupportedException, - InvalidKeyException, InvalidAlgorithmParameterException { - MacSpi mSpi = (MacSpi) new MyMacSpi(); + public void testMacSpiTests01() throws Exception { + MacSpi mSpi = new MyMacSpi(); byte [] bb1 = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5}; SecretKeySpec sks = new SecretKeySpec(bb1, "SHA1"); - assertTrue("Not MacSpi object", mSpi instanceof MacSpi); assertEquals("Incorrect MacLength", mSpi.engineGetMacLength(), 0); try { @@ -79,8 +77,7 @@ } catch (CloneNotSupportedException e) { } - MacSpi mSpi1 = (MacSpi) new MyMacSpi1(); - assertTrue("Not MacSpi object", mSpi1 instanceof MacSpi); + MacSpi mSpi1 = new MyMacSpi1(); mSpi1.clone(); byte [] bbb = new byte[10]; @@ -102,16 +99,16 @@ bb = mSpi1.engineDoFinal(); assertEquals("Incorrect result of engineDoFinal", bb.length, beforeUp); - MacSpi mSpi2 = (MacSpi) new MyMacSpi2(); - assertTrue("Not MacSpi object", mSpi2 instanceof MacSpi); + MacSpi mSpi2 = new MyMacSpi2(); mSpi2.engineInit(null, null); mSpi2.engineInit(sks, null); + try { - assertTrue((MacSpi)mSpi2.clone() instanceof MacSpi); + mSpi2.clone(); } catch (CloneNotSupportedException e) { - logln("clone() is not supported"); } + byte [] bbuf = {(byte)5, (byte)4, (byte)3, (byte)2, (byte)1}; byteBuf = ByteBuffer.allocate(5); byteBuf.put(bbuf); Index: modules/security2/test/common/unit/javax/crypto/KeyAgreementTest2.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/KeyAgreementTest2.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/KeyAgreementTest2.java (working copy) @@ -34,7 +34,7 @@ import java.security.spec.KeySpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -42,7 +42,7 @@ * */ -public class KeyAgreementTest2 extends PerformanceTest { +public class KeyAgreementTest2 extends TestCase { private static final String defaultAlg = "MyKeyAgr"; @@ -149,8 +149,6 @@ KeyAgreement keyAgr; for (int i = 0; i < validValues.length; i++) { keyAgr = KeyAgreement.getInstance(validValues[i]); - assertTrue("Not instanceof KeyAgreement object", - keyAgr instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyAgr.getProvider(), mProv); @@ -215,8 +213,6 @@ for (int i = 0; i < validValues.length; i++) { keyAgr = KeyAgreement.getInstance(validValues[i], mProv .getName()); - assertTrue("Not instanceof KeyAgreement object", - keyAgr instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyAgr.getProvider().getName(), @@ -267,8 +263,6 @@ KeySpec keySpec; for (int i = 0; i < validValues.length; i++) { keyAgr = KeyAgreement.getInstance(validValues[i], mProv); - assertTrue("Not instanceof KeyAgreement object", - keyAgr instanceof KeyAgreement); assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyAgr.getProvider(), mProv); Index: modules/security2/test/common/unit/javax/crypto/ShortBufferExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/ShortBufferExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/ShortBufferExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.crypto.ShortBufferException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ShortBufferException class constructors and methods. * */ -public class ShortBufferExceptionTest extends PerformanceTest { +public class ShortBufferExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testShortBufferException01() { ShortBufferException tE = new ShortBufferException(); - assertTrue(errNotExc, tE instanceof ShortBufferException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ ShortBufferException tE; for (int i = 0; i < msgs.length; i++) { tE = new ShortBufferException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof ShortBufferException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testShortBufferException03() { String msg = null; ShortBufferException tE = new ShortBufferException(msg); - assertTrue(errNotExc, tE instanceof ShortBufferException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/crypto/SecretKeyFactoryTest2.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/SecretKeyFactoryTest2.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/SecretKeyFactoryTest2.java (working copy) @@ -30,7 +30,7 @@ import java.security.spec.KeySpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -38,7 +38,7 @@ * */ -public class SecretKeyFactoryTest2 extends PerformanceTest { +public class SecretKeyFactoryTest2 extends TestCase { private static final String defaultAlg = "MySecretKey"; private static final String SecretKeyFactoryProviderClass = "javax.crypto.MySecretKeyFactorySpi"; Index: modules/security2/test/common/unit/javax/crypto/KeyGeneratorTest1.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/KeyGeneratorTest1.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/KeyGeneratorTest1.java (working copy) @@ -30,7 +30,7 @@ import java.security.spec.AlgorithmParameterSpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -38,7 +38,7 @@ * */ -public class KeyGeneratorTest1 extends PerformanceTest { +public class KeyGeneratorTest1 extends TestCase { /** * Constructor for KeyGeneratorTest1. @@ -89,21 +89,16 @@ } } - private KeyGenerator[] createKGs() { + private KeyGenerator[] createKGs() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); - return null; } - try { - KeyGenerator [] kg = new KeyGenerator[3]; - kg[0] = KeyGenerator.getInstance(defaultAlgorithm); - kg[1] = KeyGenerator.getInstance(defaultAlgorithm, defaultProvider); - kg[2] = KeyGenerator.getInstance(defaultAlgorithm, defaultProviderName); - return kg; - } catch (Exception e) { - logln(e.toString()); - return null; - } + + KeyGenerator [] kg = new KeyGenerator[3]; + kg[0] = KeyGenerator.getInstance(defaultAlgorithm); + kg[1] = KeyGenerator.getInstance(defaultAlgorithm, defaultProvider); + kg[2] = KeyGenerator.getInstance(defaultAlgorithm, defaultProviderName); + return kg; } @@ -120,7 +115,6 @@ KeyGeneratorSpi spi = new MyKeyGeneratorSpi(); KeyGenerator keyG = new myKeyGenerator(spi, defaultProvider, defaultAlgorithm); - assertTrue("Not KeyGenerator object", keyG instanceof KeyGenerator); assertEquals("Incorrect algorithm", keyG.getAlgorithm(), defaultAlgorithm); assertEquals("Incorrect provider", keyG.getProvider(), defaultProvider); @@ -137,7 +131,6 @@ } catch (IllegalArgumentException e) { } keyG = new myKeyGenerator(null, null, null); - assertTrue("Not KeyGenerator object", keyG instanceof KeyGenerator); assertNull("Algorithm must be null", keyG.getAlgorithm()); assertNull("Provider must be null", keyG.getProvider()); @@ -187,7 +180,6 @@ KeyGenerator keyG; for (int i = 0; i < validValues.length; i++) { keyG = KeyGenerator.getInstance(validValues[i]); - assertTrue("Not KeyGenerator object", keyG instanceof KeyGenerator); assertEquals("Incorrect algorithm", keyG.getAlgorithm(), validValues[i]); } } @@ -269,7 +261,6 @@ KeyGenerator keyG; for (int i = 0; i < validValues.length; i++) { keyG = KeyGenerator.getInstance(validValues[i], defaultProviderName); - assertTrue("Not KeyGenerator object", keyG instanceof KeyGenerator); assertEquals("Incorrect algorithm", keyG.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyG.getProvider().getName(), defaultProviderName); } @@ -335,7 +326,6 @@ KeyGenerator keyA; for (int i = 0; i < validValues.length; i++) { keyA = KeyGenerator.getInstance(validValues[i], defaultProvider); - assertTrue("Not KeyGenerator object", keyA instanceof KeyGenerator); assertEquals("Incorrect algorithm", keyA.getAlgorithm(), validValues[i]); assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider); } @@ -347,7 +337,7 @@ * Assertion: throws InvalidParameterException if keysize is wrong * */ - public void testInitKey() { + public void testInitKey() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; @@ -358,21 +348,18 @@ } int[] size = { Integer.MIN_VALUE, -1, 0, Integer.MAX_VALUE }; KeyGenerator[] kgs = createKGs(); - assertNotNull("KeyGenerator objects were not created", kgs); SecureRandom random = new SecureRandom(); + for (int i = 0; i < kgs.length; i++) { for (int j = 0; j < size.length; j++) { try { kgs[i].init(size[j]); - logln("Ignore key size: "+size[j]); - } catch (InvalidParameterException e) { + } catch (InvalidParameterException ignore) { } - } - for (int j = 0; j < size.length; j++) { + try { kgs[i].init(size[j], random); - logln("Ignore key size: "+size[j]); - } catch (InvalidParameterException e) { + } catch (InvalidParameterException ignore) { } } } @@ -383,14 +370,14 @@ * init(AlgorithmParameterSpec params, SecureRandom random) methods * Assertion: throws InvalidAlgorithmParameterException when params is null */ - public void testInitParams() { + public void testInitParams() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; } KeyGenerator [] kgs = createKGs(); - assertNotNull("KeyGenerator objects were not created", kgs); AlgorithmParameterSpec aps = null; + for (int i = 0; i < kgs.length; i++) { try { kgs[i].init(aps); @@ -417,7 +404,7 @@ * returns SecretKey object * */ - public void testGenerateKey() throws NoSuchAlgorithmException { + public void testGenerateKey() throws Exception { if (!DEFSupported) { fail(NotSupportMsg); return; @@ -426,25 +413,21 @@ String dAl = defaultAlgorithm.toUpperCase(); KeyGenerator[] kgs = createKGs(); - assertNotNull("KeyGenerator objects were not created", kgs); + for (int i = 0; i < kgs.length; i++) { sKey = kgs[i].generateKey(); - assertTrue("Not SecretKey object", sKey instanceof SecretKey); assertEquals("Incorect algorithm", sKey.getAlgorithm() .toUpperCase(), dAl); kgs[i].init(new SecureRandom()); sKey = kgs[i].generateKey(); - assertTrue("Not SecretKey object", sKey instanceof SecretKey); assertEquals("Incorect algorithm", sKey.getAlgorithm() .toUpperCase(), dAl); kgs[i].init(defaultKeySize); sKey = kgs[i].generateKey(); - assertTrue("Not SecretKey object", sKey instanceof SecretKey); assertEquals("Incorect algorithm", sKey.getAlgorithm() .toUpperCase(), dAl); kgs[i].init(defaultKeySize, new SecureRandom()); sKey = kgs[i].generateKey(); - assertTrue("Not SecretKey object", sKey instanceof SecretKey); assertEquals("Incorect algorithm", sKey.getAlgorithm() .toUpperCase(), dAl); } Index: modules/security2/test/common/unit/javax/crypto/MacTest2.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/MacTest2.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/MacTest2.java (working copy) @@ -34,7 +34,7 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -42,7 +42,7 @@ * */ -public class MacTest2 extends PerformanceTest { +public class MacTest2 extends TestCase { private static final String defaultAlg = "MyMacProv"; Index: modules/security2/test/common/unit/javax/crypto/BadPaddingExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/BadPaddingExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/BadPaddingExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.crypto.BadPaddingException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for BadPaddingException class constructors and methods. * */ -public class BadPaddingExceptionTest extends PerformanceTest { +public class BadPaddingExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testBadPaddingException01() { BadPaddingException tE = new BadPaddingException(); - assertTrue(errNotExc, tE instanceof BadPaddingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ BadPaddingException tE; for (int i = 0; i < msgs.length; i++) { tE = new BadPaddingException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof BadPaddingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -117,7 +114,6 @@ public void testBadPaddingException03() { String msg = null; BadPaddingException tE = new BadPaddingException(msg); - assertTrue(errNotExc, tE instanceof BadPaddingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/crypto/ExemptionMechanismSpiTests.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/ExemptionMechanismSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/ExemptionMechanismSpiTests.java (working copy) @@ -27,7 +27,7 @@ import java.security.Key; import java.security.spec.AlgorithmParameterSpec; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -36,7 +36,7 @@ * */ -public class ExemptionMechanismSpiTests extends PerformanceTest { +public class ExemptionMechanismSpiTests extends TestCase { /** * Constructor for ExemptionMechanismSpiTests. * Index: modules/security2/test/common/unit/javax/crypto/SecretKeyTest.java =================================================================== --- modules/security2/test/common/unit/javax/crypto/SecretKeyTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/crypto/SecretKeyTest.java (working copy) @@ -23,14 +23,14 @@ import javax.crypto.SecretKey; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SecretKey class field * */ -public class SecretKeyTest extends PerformanceTest { +public class SecretKeyTest extends TestCase { /** * Constructor for SecretKeyTest. Index: modules/security2/test/common/unit/javax/net/SocketFactoryTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/SocketFactoryTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/SocketFactoryTest.java (working copy) @@ -27,13 +27,13 @@ import java.net.SocketException; import java.net.UnknownHostException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SocketFactory class methods. */ -public class SocketFactoryTest extends PerformanceTest { +public class SocketFactoryTest extends TestCase { /* * Class under test for java.net.Socket createSocket() Index: modules/security2/test/common/unit/javax/net/ssl/KeyStoreBuilderParametersTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/KeyStoreBuilderParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/KeyStoreBuilderParametersTest.java (working copy) @@ -26,7 +26,7 @@ import java.security.KeyStore; import java.security.KeyStoreException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -34,7 +34,7 @@ * methods. * */ -public class KeyStoreBuilderParametersTest extends PerformanceTest { +public class KeyStoreBuilderParametersTest extends TestCase { /* * Class under test for void KeyStoreBuilderParameters(KeyStore.Builder) Index: modules/security2/test/common/unit/javax/net/ssl/SSLServerSocketTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLServerSocketTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLServerSocketTest.java (working copy) @@ -23,14 +23,14 @@ import java.io.IOException; import java.net.InetAddress; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLServerSocket class constructors. * */ -public class SSLServerSocketTest extends PerformanceTest { +public class SSLServerSocketTest extends TestCase { /* * Class under test for void SSLServerSocket() Index: modules/security2/test/common/unit/javax/net/ssl/SSLProtocolExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLProtocolExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLProtocolExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.net.ssl.SSLProtocolException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLProtocolException class constructors and methods. * */ -public class SSLProtocolExceptionTest extends PerformanceTest { +public class SSLProtocolExceptionTest extends TestCase { public static void main(String[] args) { } @@ -81,8 +81,6 @@ SSLProtocolException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLProtocolException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLProtocolException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -102,7 +100,6 @@ public void testSSLProtocolException02() { String msg = null; SSLProtocolException tE = new SSLProtocolException(msg); - assertTrue(errNotExc, tE instanceof SSLProtocolException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/net/ssl/SSLSessionBindingEventTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLSessionBindingEventTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLSessionBindingEventTest.java (working copy) @@ -26,14 +26,14 @@ import javax.security.cert.X509Certificate; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLSessionBindingEvent class constructors and methods. * */ -public class SSLSessionBindingEventTest extends PerformanceTest { +public class SSLSessionBindingEventTest extends TestCase { public final void testSSLSessionBindingEvent() { SSLSession ses = new MySSLSession(); Index: modules/security2/test/common/unit/javax/net/ssl/SSLSocketFactoryTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLSocketFactoryTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLSocketFactoryTest.java (working copy) @@ -25,14 +25,14 @@ import java.security.Security; import java.net.SocketException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLSocketFactory class methods. * */ -public class SSLSocketFactoryTest extends PerformanceTest { +public class SSLSocketFactoryTest extends TestCase { private SSLSocketFactory customSocketFactory; Index: modules/security2/test/common/unit/javax/net/ssl/TrustManagerFactorySpiTests.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/TrustManagerFactorySpiTests.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/TrustManagerFactorySpiTests.java (working copy) @@ -27,7 +27,7 @@ import javax.net.ssl.TrustManagerFactorySpi; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for TrustManagerFactorySpi class constructors and @@ -35,7 +35,7 @@ * */ -public class TrustManagerFactorySpiTests extends PerformanceTest { +public class TrustManagerFactorySpiTests extends TestCase { /** * Constructor for TrustManegerFactorySpiTests. * Index: modules/security2/test/common/unit/javax/net/ssl/SSLContextSpiTests.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLContextSpiTests.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLContextSpiTests.java (working copy) @@ -28,7 +28,7 @@ import javax.net.ssl.SSLContextSpi; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -36,7 +36,7 @@ * */ -public class SSLContextSpiTests extends PerformanceTest { +public class SSLContextSpiTests extends TestCase { /** * Constructor for SSLContextSpiTests. * Index: modules/security2/test/common/unit/javax/net/ssl/HttpsURLConnectionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/HttpsURLConnectionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/HttpsURLConnectionTest.java (working copy) @@ -25,14 +25,14 @@ import java.security.cert.Certificate; import java.net.URL; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for HttpsURLConnection class constructors and methods. * */ -public class HttpsURLConnectionTest extends PerformanceTest { +public class HttpsURLConnectionTest extends TestCase { public final void testGetPeerPrincipal() { HttpsURLConnection con = new MyHttpsURLConnection(null); Index: modules/security2/test/common/unit/javax/net/ssl/DefaultSSLSocketFactoryTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/DefaultSSLSocketFactoryTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/DefaultSSLSocketFactoryTest.java (working copy) @@ -25,7 +25,7 @@ import java.net.Socket; import java.net.SocketException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -33,7 +33,7 @@ * methods. * */ -public class DefaultSSLSocketFactoryTest extends PerformanceTest { +public class DefaultSSLSocketFactoryTest extends TestCase { /* * Class under test for Socket createSocket(String, int) Index: modules/security2/test/common/unit/javax/net/ssl/KeyManagerFactorySpiTests.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/KeyManagerFactorySpiTests.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/KeyManagerFactorySpiTests.java (working copy) @@ -28,7 +28,7 @@ import javax.net.ssl.KeyManagerFactorySpi; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -36,7 +36,7 @@ * */ -public class KeyManagerFactorySpiTests extends PerformanceTest { +public class KeyManagerFactorySpiTests extends TestCase { /** * Constructor for KeyManegerFactorySpiTests. Index: modules/security2/test/common/unit/javax/net/ssl/SSLPermissionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLPermissionTest.java (working copy) @@ -20,13 +20,13 @@ */ package javax.net.ssl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLPermission class constructors. * */ -public class SSLPermissionTest extends PerformanceTest { +public class SSLPermissionTest extends TestCase { /* * Class under test for void SSLPermission(String) Index: modules/security2/test/common/unit/javax/net/ssl/SSLSocketTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLSocketTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLSocketTest.java (working copy) @@ -25,14 +25,14 @@ import java.net.ServerSocket; import java.net.UnknownHostException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLSocket class constructors. * */ -public class SSLSocketTest extends PerformanceTest { +public class SSLSocketTest extends TestCase { /* * Class under test for void SSLSocket() Index: modules/security2/test/common/unit/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLPeerUnverifiedExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import javax.net.ssl.SSLPeerUnverifiedException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class SSLPeerUnverifiedExceptionTest extends PerformanceTest { +public class SSLPeerUnverifiedExceptionTest extends TestCase { public static void main(String[] args) { } @@ -82,8 +82,6 @@ SSLPeerUnverifiedException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLPeerUnverifiedException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLPeerUnverifiedException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -103,7 +101,6 @@ public void testSSLPeerUnverifiedException02() { String msg = null; SSLPeerUnverifiedException tE = new SSLPeerUnverifiedException(msg); - assertTrue(errNotExc, tE instanceof SSLPeerUnverifiedException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/net/ssl/SSLExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.net.ssl.SSLException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLException class constructors and methods. * */ -public class SSLExceptionTest extends PerformanceTest { +public class SSLExceptionTest extends TestCase { public static void main(String[] args) { } @@ -81,8 +81,6 @@ SSLException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -101,7 +99,6 @@ public void testSSLException02() { String msg = null; SSLException tE = new SSLException(msg); - assertTrue(errNotExc, tE instanceof SSLException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -118,7 +115,6 @@ public void testSSLException03() { Throwable cause = null; SSLException tE = new SSLException(cause); - assertTrue(errNotExc, tE instanceof SSLException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -134,7 +130,6 @@ */ public void testSSLException04() { SSLException tE = new SSLException(tCause); - assertTrue(errNotExc, tE instanceof SSLException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -162,7 +157,6 @@ */ public void testSSLException05() { SSLException tE = new SSLException(null, null); - assertTrue(errNotExc, tE instanceof SSLException); assertNull("getMessage() must return null", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -181,8 +175,6 @@ SSLException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLException(msgs[i], null); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -201,7 +193,6 @@ */ public void testSSLException07() { SSLException tE = new SSLException(null, tCause); - assertTrue(errNotExc, tE instanceof SSLException); if (tE.getMessage() != null) { String toS = tCause.toString(); String getM = tE.getMessage(); @@ -231,8 +222,6 @@ SSLException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLException(msgs[i], tCause); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLException); String getM = tE.getMessage(); String toS = tCause.toString(); if (msgs[i].length() > 0) { Index: modules/security2/test/common/unit/javax/net/ssl/HandshakeCompletedEventTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/HandshakeCompletedEventTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/HandshakeCompletedEventTest.java (working copy) @@ -24,7 +24,7 @@ import java.io.IOException; import javax.net.SocketFactory; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import java.net.ServerSocket; import java.security.cert.Certificate; @@ -34,7 +34,7 @@ * Tests for HandshakeCompletedEvent class constructors and methods. * */ -public class HandshakeCompletedEventTest extends PerformanceTest { +public class HandshakeCompletedEventTest extends TestCase { int port; Index: modules/security2/test/common/unit/javax/net/ssl/SSLEngineResultTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLEngineResultTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLEngineResultTest.java (working copy) @@ -21,14 +21,14 @@ package javax.net.ssl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Template tests for SSLEngineResult class * FIXME: uncommente these tests * */ -public class SSLEngineResultTest extends PerformanceTest { +public class SSLEngineResultTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(SSLEngineResultTest.class); Index: modules/security2/test/common/unit/javax/net/ssl/SSLHandshakeExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLHandshakeExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLHandshakeExceptionTest.java (working copy) @@ -23,7 +23,7 @@ import javax.net.ssl.SSLHandshakeException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -31,7 +31,7 @@ * methods. * */ -public class SSLHandshakeExceptionTest extends PerformanceTest { +public class SSLHandshakeExceptionTest extends TestCase { public static void main(String[] args) { } @@ -82,8 +82,6 @@ SSLHandshakeException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLHandshakeException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLHandshakeException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -103,7 +101,6 @@ public void testSSLHandshakeException02() { String msg = null; SSLHandshakeException tE = new SSLHandshakeException(msg); - assertTrue(errNotExc, tE instanceof SSLHandshakeException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/net/ssl/SSLKeyExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLKeyExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLKeyExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.net.ssl.SSLKeyException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLKeyException class constructors and methods. * */ -public class SSLKeyExceptionTest extends PerformanceTest { +public class SSLKeyExceptionTest extends TestCase { public static void main(String[] args) { } @@ -81,8 +81,6 @@ SSLKeyException tE; for (int i = 0; i < msgs.length; i++) { tE = new SSLKeyException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof SSLKeyException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -101,7 +99,6 @@ public void testSSLKeyException02() { String msg = null; SSLKeyException tE = new SSLKeyException(msg); - assertTrue(errNotExc, tE instanceof SSLKeyException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/net/ssl/SSLServerSocketFactoryTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/SSLServerSocketFactoryTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/SSLServerSocketFactoryTest.java (working copy) @@ -25,14 +25,14 @@ import java.security.Security; import java.net.SocketException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for SSLSocketFactory class methods. * */ -public class SSLServerSocketFactoryTest extends PerformanceTest { +public class SSLServerSocketFactoryTest extends TestCase { private SSLServerSocketFactory customServerSocketFactory; Index: modules/security2/test/common/unit/javax/net/ssl/X509ExtendedKeyManagerTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/X509ExtendedKeyManagerTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/X509ExtendedKeyManagerTest.java (working copy) @@ -28,14 +28,14 @@ import javax.net.ssl.X509ExtendedKeyManager; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for X509ExtendedKeyManager class constructors and methods. * */ -public class X509ExtendedKeyManagerTest extends PerformanceTest { +public class X509ExtendedKeyManagerTest extends TestCase { public final void testChooseEngineClientAlias() { X509ExtendedKeyManager km = new MyX509ExtendedKeyManager(); Index: modules/security2/test/common/unit/javax/net/ssl/CertPathTrustManagerParametersTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/CertPathTrustManagerParametersTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/CertPathTrustManagerParametersTest.java (working copy) @@ -22,7 +22,7 @@ import java.security.cert.CertPathParameters; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** @@ -30,7 +30,7 @@ * and methods. * */ -public class CertPathTrustManagerParametersTest extends PerformanceTest { +public class CertPathTrustManagerParametersTest extends TestCase { public void testCertPathTrustManagerParameters() { CertPathParameters parameters = new MyCertPathParameters(); Index: modules/security2/test/common/unit/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ssl/DefaultSSLServerSocketFactoryTest.java (working copy) @@ -24,14 +24,14 @@ import java.net.InetAddress; import java.net.SocketException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DefaultSSLServerSocketFactory class constructors and methods. * */ -public class DefaultSSLServerSocketFactoryTest extends PerformanceTest { +public class DefaultSSLServerSocketFactoryTest extends TestCase { /* * Class under test for ServerSocket createServerSocket(int) Index: modules/security2/test/common/unit/javax/net/ServerSocketFactoryTest.java =================================================================== --- modules/security2/test/common/unit/javax/net/ServerSocketFactoryTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/net/ServerSocketFactoryTest.java (working copy) @@ -27,14 +27,14 @@ import java.net.SocketException; import java.net.UnknownHostException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for ServerSocketFactory class constructors and methods. */ -public class ServerSocketFactoryTest extends PerformanceTest { +public class ServerSocketFactoryTest extends TestCase { /* * Class under test for java.net.ServerSocket createServerSocket() */ Index: modules/security2/test/common/unit/javax/security/auth/PolicyTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/PolicyTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/PolicyTest.java (working copy) @@ -33,14 +33,14 @@ import java.security.cert.Certificate; import java.util.Enumeration; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.test.SecurityChecker; /** * Tests Policy class */ -public class PolicyTest extends PerformanceTest { +public class PolicyTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(PolicyTest.class); Index: modules/security2/test/common/unit/javax/security/auth/AuthPermissionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/AuthPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/AuthPermissionTest.java (working copy) @@ -21,12 +21,12 @@ package javax.security.auth; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests AuthPermission class */ -public class AuthPermissionTest extends PerformanceTest { +public class AuthPermissionTest extends TestCase { private AuthPermission ap; private AuthPermission ap1; Index: modules/security2/test/common/unit/javax/security/auth/callback/PasswordCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/PasswordCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/PasswordCallbackTest.java (working copy) @@ -22,13 +22,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests PasswordCallback class */ -public class PasswordCallbackTest extends PerformanceTest { +public class PasswordCallbackTest extends TestCase { PasswordCallback pc; Index: modules/security2/test/common/unit/javax/security/auth/callback/LanguageCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/LanguageCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/LanguageCallbackTest.java (working copy) @@ -24,13 +24,13 @@ import java.util.Locale; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests LanguageCallback class */ -public class LanguageCallbackTest extends PerformanceTest { +public class LanguageCallbackTest extends TestCase { LanguageCallback lc; Index: modules/security2/test/common/unit/javax/security/auth/callback/TextInputCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/TextInputCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/TextInputCallbackTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests TextInputCallback class */ -public class TextInputCallbackTest extends PerformanceTest { +public class TextInputCallbackTest extends TestCase { TextInputCallback text = null; Index: modules/security2/test/common/unit/javax/security/auth/callback/TextOutputCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/TextOutputCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/TextOutputCallbackTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests TextOutputCallback class */ -public class TextOutputCallbackTest extends PerformanceTest { +public class TextOutputCallbackTest extends TestCase { TextOutputCallback text = null; Index: modules/security2/test/common/unit/javax/security/auth/callback/UnsupportedCallbackExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/UnsupportedCallbackExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/UnsupportedCallbackExceptionTest.java (working copy) @@ -22,13 +22,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests UnsupportedCallbackException class */ -public class UnsupportedCallbackExceptionTest extends PerformanceTest { +public class UnsupportedCallbackExceptionTest extends TestCase { NameCallback nc = new NameCallback("prompt"); Index: modules/security2/test/common/unit/javax/security/auth/callback/ConfirmationCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/ConfirmationCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/ConfirmationCallbackTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests ConfirmationCallback class */ -public class ConfirmationCallbackTest extends PerformanceTest { +public class ConfirmationCallbackTest extends TestCase { ConfirmationCallback cc; int mt[] = { ConfirmationCallback.INFORMATION, Index: modules/security2/test/common/unit/javax/security/auth/callback/ChoiceCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/ChoiceCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/ChoiceCallbackTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests ChoiceCallback class */ -public class ChoiceCallbackTest extends PerformanceTest { +public class ChoiceCallbackTest extends TestCase { ChoiceCallback cb; Index: modules/security2/test/common/unit/javax/security/auth/callback/NameCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/callback/NameCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/callback/NameCallbackTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.callback; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests NameCallback class */ -public class NameCallbackTest extends PerformanceTest { +public class NameCallbackTest extends TestCase { NameCallback nc; Index: modules/security2/test/common/unit/javax/security/auth/DestroyFailedExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/DestroyFailedExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/DestroyFailedExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests DestroyFailedException class */ -public class DestroyFailedExceptionTest extends PerformanceTest { +public class DestroyFailedExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DestroyFailedExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/PrivateCredentialPermissionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/PrivateCredentialPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/PrivateCredentialPermissionTest.java (working copy) @@ -27,13 +27,13 @@ import java.security.Principal; import java.util.HashSet; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests PrivateCredentialPermission class implementation. */ -public class PrivateCredentialPermissionTest extends PerformanceTest { +public class PrivateCredentialPermissionTest extends TestCase { private PrivateCredentialPermission p_that = null; @@ -57,14 +57,6 @@ } /** - * number of iterations in performance mode - * @see org.apache.harmony.security.test.PerformanceTest#getRepeatCount() - */ - public long getRepeatCount() { - return 100000; - } - - /** * [C1 P1 "duke"] implies [C1 P1 "duke" P2 "nuke"]. */ public final void testImplies_01() { Index: modules/security2/test/common/unit/javax/security/auth/login/CredentialNotFoundExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/CredentialNotFoundExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/CredentialNotFoundExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests CredentialNotFoundException class */ -public class CredentialNotFoundExceptionTest extends PerformanceTest { +public class CredentialNotFoundExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CredentialNotFoundExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/ConfigurationTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/ConfigurationTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/ConfigurationTest.java (working copy) @@ -26,13 +26,13 @@ import javax.security.auth.AuthPermission; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests Configuration class */ -public class ConfigurationTest extends PerformanceTest { +public class ConfigurationTest extends TestCase { /** * Easy the SecurityManager class Index: modules/security2/test/common/unit/javax/security/auth/login/LoginExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/LoginExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/LoginExceptionTest.java (working copy) @@ -21,12 +21,12 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests LoginException class */ -public class LoginExceptionTest extends PerformanceTest { +public class LoginExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(LoginExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/AccountNotFoundExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/AccountNotFoundExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/AccountNotFoundExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests AccountNotFoundException class */ -public class AccountNotFoundExceptionTest extends PerformanceTest { +public class AccountNotFoundExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AccountNotFoundExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/CredentialExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/CredentialExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/CredentialExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests CredentialException class */ -public class CredentialExceptionTest extends PerformanceTest { +public class CredentialExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CredentialExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/CredentialExpiredExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/CredentialExpiredExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/CredentialExpiredExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests CredentialExpiredException class */ -public class CredentialExpiredExceptionTest extends PerformanceTest { +public class CredentialExpiredExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(CredentialExpiredException.class); Index: modules/security2/test/common/unit/javax/security/auth/login/AccountExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/AccountExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/AccountExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests AccountException class */ -public class AccountExceptionTest extends PerformanceTest { +public class AccountExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AccountExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/AccountExpiredExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/AccountExpiredExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/AccountExpiredExceptionTest.java (working copy) @@ -21,14 +21,14 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests AccountExpiredException class */ -public class AccountExpiredExceptionTest extends PerformanceTest { +public class AccountExpiredExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AccountExpiredExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/FailedLoginExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/FailedLoginExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/FailedLoginExceptionTest.java (working copy) @@ -21,12 +21,12 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests FailedLoginException class */ -public class FailedLoginExceptionTest extends PerformanceTest { +public class FailedLoginExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(FailedLoginExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/AccountLockedExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/AccountLockedExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/AccountLockedExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.auth.login; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests AccountLockedException class */ -public class AccountLockedExceptionTest extends PerformanceTest { +public class AccountLockedExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AccountLockedExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/login/LoginContextTest_1.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/login/LoginContextTest_1.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/login/LoginContextTest_1.java (working copy) @@ -50,13 +50,13 @@ import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Unit tests for LoginContext */ -public class LoginContextTest_1 extends PerformanceTest { +public class LoginContextTest_1 extends TestCase { private static final String CONFIG_NAME = "testConfiguration"; Index: modules/security2/test/common/unit/javax/security/auth/kerberos/DelegationPermissionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/kerberos/DelegationPermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/kerberos/DelegationPermissionTest.java (working copy) @@ -31,13 +31,13 @@ import java.util.Enumeration; import java.util.NoSuchElementException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests DelegationPermission class implementation. */ -public class DelegationPermissionTest extends PerformanceTest { +public class DelegationPermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(DelegationPermissionTest.class); Index: modules/security2/test/common/unit/javax/security/auth/kerberos/ServicePermissionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/auth/kerberos/ServicePermissionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/auth/kerberos/ServicePermissionTest.java (working copy) @@ -29,14 +29,14 @@ import java.util.Enumeration; import java.util.NoSuchElementException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests ServicePermission class implementation. */ -public class ServicePermissionTest extends PerformanceTest { +public class ServicePermissionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(ServicePermissionTest.class); Index: modules/security2/test/common/unit/javax/security/sasl/SaslExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/SaslExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/SaslExceptionTest.java (working copy) @@ -22,13 +22,13 @@ package javax.security.sasl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for constructors and methods of SaslException class * */ -public class SaslExceptionTest extends PerformanceTest { +public class SaslExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(SaslExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/sasl/SaslTest1.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/SaslTest1.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/SaslTest1.java (working copy) @@ -26,14 +26,14 @@ import java.security.Security; import java.util.Enumeration; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Test for Sasl class * */ -public class SaslTest1 extends PerformanceTest { +public class SaslTest1 extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(SaslTest1.class); Index: modules/security2/test/common/unit/javax/security/sasl/SaslTest2.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/SaslTest2.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/SaslTest2.java (working copy) @@ -27,7 +27,7 @@ import javax.security.auth.callback.CallbackHandler; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import java.util.Enumeration; import java.util.Map; @@ -37,7 +37,7 @@ * */ -public class SaslTest2 extends PerformanceTest { +public class SaslTest2 extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(SaslTest2.class); Index: modules/security2/test/common/unit/javax/security/sasl/SaslTest3.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/SaslTest3.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/SaslTest3.java (working copy) @@ -35,14 +35,14 @@ import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Test for Sasl class * */ -public class SaslTest3 extends PerformanceTest { +public class SaslTest3 extends TestCase { private static final String CLNTSRV = "SaslClientFactory."; private static final String fClientClass = "javax.security.sasl.mySaslClientFactory"; Index: modules/security2/test/common/unit/javax/security/sasl/SaslTest4.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/SaslTest4.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/SaslTest4.java (working copy) @@ -32,14 +32,14 @@ import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.harmony.security.SpiEngUtils; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Test for Sasl class * */ -public class SaslTest4 extends PerformanceTest { +public class SaslTest4 extends TestCase { private static final String SRVSSRV = "SaslServerFactory."; private static final String fServerClass = "javax.security.sasl.mySaslServerFactory"; Index: modules/security2/test/common/unit/javax/security/sasl/AuthorizeCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/AuthorizeCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/AuthorizeCallbackTest.java (working copy) @@ -21,14 +21,14 @@ package javax.security.sasl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for constructor and methods of AuthorizeCallback class * */ -public class AuthorizeCallbackTest extends PerformanceTest { +public class AuthorizeCallbackTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AuthorizeCallbackTest.class); Index: modules/security2/test/common/unit/javax/security/sasl/RealmChoiceCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/RealmChoiceCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/RealmChoiceCallbackTest.java (working copy) @@ -21,14 +21,14 @@ package javax.security.sasl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for constructor and methods ofRealmChoiceCallback class * */ -public class RealmChoiceCallbackTest extends PerformanceTest { +public class RealmChoiceCallbackTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(RealmChoiceCallbackTest.class); Index: modules/security2/test/common/unit/javax/security/sasl/RealmCallbackTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/RealmCallbackTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/RealmCallbackTest.java (working copy) @@ -21,7 +21,7 @@ package javax.security.sasl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; ; /** @@ -29,7 +29,7 @@ * */ -public class RealmCallbackTest extends PerformanceTest { +public class RealmCallbackTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(RealmCallbackTest.class); Index: modules/security2/test/common/unit/javax/security/sasl/AuthenticationExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/sasl/AuthenticationExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/sasl/AuthenticationExceptionTest.java (working copy) @@ -21,13 +21,13 @@ package javax.security.sasl; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for constructors and methods of AuthenticationException class * */ -public class AuthenticationExceptionTest extends PerformanceTest { +public class AuthenticationExceptionTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(AuthenticationExceptionTest.class); Index: modules/security2/test/common/unit/javax/security/cert/CertificateExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/cert/CertificateExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/cert/CertificateExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.security.cert.CertificateException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class CertificateExceptionTest extends PerformanceTest { +public class CertificateExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertificateException01() { CertificateException tE = new CertificateException(); - assertTrue(errNotExc, tE instanceof CertificateException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertificateException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testCertificateException03() { String msg = null; CertificateException tE = new CertificateException(msg); - assertTrue(errNotExc, tE instanceof CertificateException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/security/cert/CertificateExpiredExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/cert/CertificateExpiredExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/cert/CertificateExpiredExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.security.cert.CertificateExpiredException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class CertificateExpiredExceptionTest extends PerformanceTest { +public class CertificateExpiredExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertificateExpiredException01() { CertificateExpiredException tE = new CertificateExpiredException(); - assertTrue(errNotExc, tE instanceof CertificateExpiredException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertificateExpiredException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateExpiredException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateExpiredException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testCertificateExpiredException03() { String msg = null; CertificateExpiredException tE = new CertificateExpiredException(msg); - assertTrue(errNotExc, tE instanceof CertificateExpiredException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/security/cert/CertificateNotYetValidExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/cert/CertificateNotYetValidExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/cert/CertificateNotYetValidExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.security.cert.CertificateNotYetValidException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class CertificateNotYetValidExceptionTest extends PerformanceTest { +public class CertificateNotYetValidExceptionTest extends TestCase { public static void main(String[] args) { } @@ -80,7 +80,6 @@ */ public void testCertificateNotYetValidException01() { CertificateNotYetValidException tE = new CertificateNotYetValidException(); - assertTrue(errNotExc, tE instanceof CertificateNotYetValidException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -99,8 +98,6 @@ CertificateNotYetValidException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateNotYetValidException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateNotYetValidException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -121,7 +118,6 @@ String msg = null; CertificateNotYetValidException tE = new CertificateNotYetValidException( msg); - assertTrue(errNotExc, tE instanceof CertificateNotYetValidException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/security/cert/CertificateParsingExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/cert/CertificateParsingExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/cert/CertificateParsingExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.security.cert.CertificateParsingException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class CertificateParsingExceptionTest extends PerformanceTest { +public class CertificateParsingExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertificateParsingException01() { CertificateParsingException tE = new CertificateParsingException(); - assertTrue(errNotExc, tE instanceof CertificateParsingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertificateParsingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateParsingException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateParsingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testCertificateParsingException03() { String msg = null; CertificateParsingException tE = new CertificateParsingException(msg); - assertTrue(errNotExc, tE instanceof CertificateParsingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/common/unit/javax/security/cert/CertificateEncodingExceptionTest.java =================================================================== --- modules/security2/test/common/unit/javax/security/cert/CertificateEncodingExceptionTest.java (revision 373503) +++ modules/security2/test/common/unit/javax/security/cert/CertificateEncodingExceptionTest.java (working copy) @@ -23,14 +23,14 @@ import javax.security.cert.CertificateEncodingException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; /** * Tests for DigestException class constructors and methods. * */ -public class CertificateEncodingExceptionTest extends PerformanceTest { +public class CertificateEncodingExceptionTest extends TestCase { public static void main(String[] args) { } @@ -78,7 +78,6 @@ */ public void testCertificateEncodingException01() { CertificateEncodingException tE = new CertificateEncodingException(); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { @@ -97,8 +96,6 @@ CertificateEncodingException tE; for (int i = 0; i < msgs.length; i++) { tE = new CertificateEncodingException(msgs[i]); - assertTrue(errNotExc.concat(" (msg: ").concat(msgs[i]).concat(")"), - tE instanceof CertificateEncodingException); assertEquals("getMessage() must return: ".concat(msgs[i]), tE .getMessage(), msgs[i]); assertNull("getCause() must return null", tE.getCause()); @@ -118,7 +115,6 @@ public void testCertificateEncodingException03() { String msg = null; CertificateEncodingException tE = new CertificateEncodingException(msg); - assertTrue(errNotExc, tE instanceof CertificateEncodingException); assertNull("getMessage() must return null.", tE.getMessage()); assertNull("getCause() must return null", tE.getCause()); try { Index: modules/security2/test/windows/unit/org/apache/harmony/security/x/security/auth/module/NTLoginModuleTest.java =================================================================== --- modules/security2/test/windows/unit/org/apache/harmony/security/x/security/auth/module/NTLoginModuleTest.java (revision 373503) +++ modules/security2/test/windows/unit/org/apache/harmony/security/x/security/auth/module/NTLoginModuleTest.java (working copy) @@ -28,14 +28,14 @@ import javax.security.auth.callback.Callback; import javax.security.auth.login.LoginException; -import org.apache.harmony.security.test.PerformanceTest; +import junit.framework.TestCase; import org.apache.harmony.security.x.security.auth.module.NTLoginModule; /** * Unit test for NTLoginModule */ -public class NTLoginModuleTest extends PerformanceTest { +public class NTLoginModuleTest extends TestCase { /** * Standalone entry point.