db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fuzzylo...@apache.org
Subject svn commit: r155990 [3/15] - in incubator/derby/code/trunk: ./ java/testing/ java/testing/org/apache/derbyTesting/functionTests/harness/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/suites/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/functionTests/tests/store/ java/testing/org/apache/derbyTesting/functionTests/tests/unit/ java/testing/org/apache/derbyTesting/unitTests/ java/testing/org/apache/derbyTesting/unitTests/crypto/ java/testing/org/apache/derbyTesting/unitTests/harness/ java/testing/org/apache/derbyTesting/unitTests/lang/ java/testing/org/apache/derbyTesting/unitTests/services/ java/testing/org/apache/derbyTesting/unitTests/store/ java/testing/org/apache/derbyTesting/unitTests/util/
Date Thu, 03 Mar 2005 01:30:45 GMT
Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecoveryFail_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecoveryFail_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecoveryFail_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecoveryFail_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverFullLog=org.apache.derbyTesting.unitTests.store.T_RecoverFullLog
+TestFullRecoveryFail=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecoveryFail_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecovery_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecovery_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecovery_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecovery_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverFullLog=org.apache.derbyTesting.unitTests.store.T_RecoverFullLog
+TestFullRecover=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/fullRecovery_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/logSwitchFail_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/logSwitchFail_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/logSwitchFail_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/logSwitchFail_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,5 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.storage.logSwitchInterval=100000
+derby.module.test.recoverFullLog=org.apache.derbyTesting.unitTests.store.T_RecoverFullLog
+TestLogSwitchFail=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/logSwitchFail_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/readme
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/readme?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/readme (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/readme Wed Mar  2 17:30:05 2005
@@ -0,0 +1,2 @@
+This directory provides the link between the functionTest and the 
+UnitTest harnesses. 

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog1_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog1_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog1_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog1_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog1=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog1_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog2_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog2_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog2_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog2_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog2=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog2_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog3_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog3_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog3_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog3_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog3=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog3_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog4_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog4_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog4_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog4_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog4=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog4_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog5_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog5_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog5_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog5_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog5=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog5_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog6_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog6_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog6_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog6_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog6=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog6_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog7_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog7_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog7_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog7_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLog7=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLog7_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLogSetup_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLogSetup_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLogSetup_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLogSetup_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recoverBadLog=org.apache.derbyTesting.unitTests.store.T_RecoverBadLog
+TestBadLogSetup=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverBadLogSetup_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverySetup_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverySetup_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverySetup_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverySetup_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recovery=org.apache.derbyTesting.unitTests.store.T_Recovery
+SetupRecovery=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoverySetup_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoveryTest_derby.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoveryTest_derby.properties?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoveryTest_derby.properties (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoveryTest_derby.properties Wed Mar  2 17:30:05 2005
@@ -0,0 +1,4 @@
+derby.module.testManager=org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+derby.infolog.append=true
+derby.module.test.recovery=org.apache.derbyTesting.unitTests.store.T_Recovery
+TestRecovery=true

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/unit/recoveryTest_derby.properties
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,650 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.crypto.T_Cipher
+
+   Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.crypto;
+
+import org.apache.derbyTesting.unitTests.harness.T_Generic;
+import org.apache.derbyTesting.unitTests.harness.T_Fail;
+
+import org.apache.derby.iapi.services.crypto.*;
+
+import org.apache.derby.iapi.services.monitor.Monitor;
+
+import org.apache.derby.iapi.db.PropertyInfo;
+
+import org.apache.derby.iapi.error.StandardException;
+
+import java.security.Key;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+
+import java.util.Properties;
+
+
+/*
+// PT
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.spec.KeySpec;
+import java.security.AlgorithmParameters;
+// import java.security.spec.AlgorithmParameterSpec;
+import javax.crypto.spec.IvParameterSpec;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+import java.lang.reflect.*;
+*/
+
+
+/*
+	To run, put the following line in derby.properties
+	derby.module.test.T_Cipher=org.apache.derbyTesting.unitTests.crypto.T_Cipher
+
+	and run java org.apache.derbyTesting.unitTests.harness.UnitTestMain
+
+*/
+public class T_Cipher extends T_Generic
+{
+	private static final String testService = "CipherText";
+
+	CipherProvider enEngine;
+	CipherProvider deEngine;
+	Key secretKey;
+	byte[] IV;
+
+	CipherFactory factory;
+
+	public T_Cipher()
+	{
+		super();
+	}
+
+	/*
+	** Methods required by T_Generic
+	*/
+
+	public String getModuleToTestProtocolName() {
+		return org.apache.derby.iapi.reference.Module.CipherFactory;
+	}
+
+    protected String getAlgorithm()
+    {
+        return "DES/CBC/NoPadding";
+    }
+
+    protected String getProvider()
+    {
+	// allow for alternate providers
+	String testProvider = System.getProperty("testEncryptionProvider");
+	if (testProvider != null) 
+		return testProvider;
+	else
+		return null;	
+
+    }
+
+	public void runTests() throws T_Fail {
+
+		File testFile = new File("extinout/T_Cipher.data");
+		if (testFile.exists())
+			testFile.delete();
+
+		String bootPassword = "a secret, don't tell anyone";
+
+		try
+		{
+							
+			//if external input output files dir does not exist ,create one
+			File ifdir = new File("extinout");
+			if(!ifdir.exists())
+				ifdir.mkdirs();
+
+			RandomAccessFile file = new RandomAccessFile(testFile, "rw");
+
+			setupCiphers(bootPassword);
+
+			// run thru some in patterns
+			int patternLength = 8192;
+			byte[] pattern = new byte[patternLength];
+			for (int i = 0; i < patternLength; i++)
+				pattern[i] = (byte)(i & 0xFF);
+
+			test(pattern, 0, 8, file);	// test short patterns
+			test(pattern, 8, 8, file);
+			test(pattern, 1, 16, file);
+
+			test(pattern, 0, patternLength, file); // test long pattern
+			test(pattern, 0, patternLength/2, file);
+			test(pattern, 1, patternLength/2, file);
+			test(pattern, 2, patternLength/2, file);
+			test(pattern, 3, patternLength/2, file);
+
+			file.seek(0);
+			check(pattern, 0, 8, file);	// file offset 0
+			check(pattern, 8, 8, file);	// file offset 8
+			check(pattern, 1, 16, file);	// file offset 16
+			check(pattern, 0, patternLength, file);	// file offset 32
+			check(pattern, 0, patternLength/2, file);// file offset 32+patternLength
+			check(pattern, 1, patternLength/2, file);// file offset 32+patternLength+(patternLength/2)
+			check(pattern, 2, patternLength/2, file);// file offset 32+(2*patternLength)
+			check(pattern, 3, patternLength/2, file);// file offset 32+(2*patternLength)+(patternLength/2);
+
+			REPORT("starting random test");
+
+			// now do some random testing from file
+			file.seek(32+patternLength);
+			check(pattern, 0, patternLength/2, file);
+
+			file.seek(32);
+			check(pattern, 0, patternLength, file);
+
+			file.seek(32+(2*patternLength));
+			check(pattern, 2, patternLength/2, file);
+
+			file.seek(0);
+			check(pattern, 0, 8, file);
+
+			file.seek(16);
+			check(pattern, 1, 16, file);
+
+			file.seek(32+(2*patternLength)+(patternLength/2));
+			check(pattern, 3, patternLength/2, file);
+
+			file.seek(8);
+			check(pattern, 8, 8, file);
+
+			file.seek(32+patternLength+(patternLength/2));
+			check(pattern, 1, patternLength/2, file);
+
+			file.close();
+
+			// test streaming
+			File streamFile = new File("extinout/T_CipherStream.data");
+			if (streamFile.exists())
+				streamFile.delete();
+
+			// RESOLVE: defectId 1834
+			if (false)
+			{
+/*				OutputStream enOutputStream =
+					factory.createNewCipherOutputStream(
+						new FileOutputStream(streamFile), factory.ENCRYPT, secretKey, IV);
+
+				int encryptLength = patternLength; // make it a length that is
+												   // not on 8 bytes boundary
+				enOutputStream.write(pattern, 0, encryptLength);
+				enOutputStream.write(pattern, 0, 3); // write a couple of bytes of
+												 // garbage at the end
+				enOutputStream.close();
+				enOutputStream = null;
+
+				InputStream inStream = new FileInputStream(streamFile);
+				byte[] check = new byte[encryptLength + 100];
+				int r = inStream.read(check);
+				inStream.close();
+				REPORT("Stream of " + encryptLength + " is encrypted into " + r + " length");
+				if (byteArrayIdentical(check, pattern, 0, encryptLength))
+					throw T_Fail.testFailMsg("encryption stream did not encrypt");
+
+				InputStream deInputStream =
+					factory.createNewCipherInputStream(
+						new FileInputStream(streamFile), factory.DECRYPT, secretKey, IV);
+
+				int totalRead = 0;
+				while((r = deInputStream.read(check, totalRead, check.length-totalRead)) != -1)
+					totalRead += r;
+
+				if (totalRead != encryptLength)
+					throw T_Fail.testFailMsg("decrypted stream is " + totalRead + " is not the same length");
+				if (byteArrayIdentical(check, pattern, 0, encryptLength) == false)
+					throw T_Fail.testFailMsg("decryption stream did not decrypt");
+				deInputStream.close();
+*/
+			}
+		}
+		catch (StandardException se)
+		{
+			se.printStackTrace(System.out);
+			throw T_Fail.exceptionFail(se);
+		}
+		catch (IOException ioe)
+		{
+			throw T_Fail.exceptionFail(ioe);
+		}
+
+
+		PASS("T_Cipher");
+	}
+
+
+	protected void setupCiphers(String bootPassword) throws T_Fail, StandardException
+	{
+        // set properties for testing
+        Properties props = new Properties();
+        props.put("encryptionAlgorithm",getAlgorithm());
+        String provider = getProvider();
+        if (provider != null)
+            props.put("encryptionProvider",getProvider());
+		props.put("bootPassword", bootPassword);
+
+        REPORT("encryption algorithm used : " + getAlgorithm());
+        REPORT("encryption provider used : " + provider);
+
+		factory = (CipherFactory)Monitor.bootServiceModule(true, (Object)null,
+            org.apache.derby.iapi.reference.Module.CipherFactory, props);
+		if (factory == null)
+			throw T_Fail.testFailMsg("cannot find Cipher factory ");
+
+		enEngine = factory.createNewCipher(CipherFactory.ENCRYPT);
+		deEngine = factory.createNewCipher(CipherFactory.DECRYPT);
+
+		if (enEngine == null)
+			throw T_Fail.testFailMsg("cannot create encryption engine");
+		if (deEngine == null)
+			throw T_Fail.testFailMsg("cannot create decryption engine");
+	}
+
+	protected void test(byte[] cleartext, int offset, int length,
+					  RandomAccessFile outfile)
+		 throws T_Fail, StandardException, IOException
+	{
+		byte[] ciphertext = new byte[length];
+		System.arraycopy(cleartext, offset, ciphertext, 0, length);
+
+		if (enEngine.encrypt(ciphertext, 0, length, ciphertext, 0) != length)
+			throw T_Fail.testFailMsg("encrypted text length != length");
+
+		if (byteArrayIdentical(ciphertext, cleartext, offset, length))
+			throw T_Fail.testFailMsg("encryption just made a copy of the clear text");
+
+		outfile.write(ciphertext);
+
+		// now decrypt it and check
+		deEngine.decrypt(ciphertext, 0, length, ciphertext, 0);
+		if (byteArrayIdentical(ciphertext, cleartext, offset, length) == false)
+			throw T_Fail.testFailMsg("decryption did not yield the same clear text");
+	}
+
+	protected void check(byte[] cleartext, int offset, int length,
+					   RandomAccessFile infile)
+		 throws IOException, T_Fail, StandardException
+	{
+		byte[] ciphertext = new byte[length];
+		infile.read(ciphertext);
+
+		if (deEngine.decrypt(ciphertext, 0, length, ciphertext, 0) != length)
+			throw T_Fail.testFailMsg("decrypted text length != length");
+
+		if (byteArrayIdentical(ciphertext, cleartext, offset, length) == false)
+			throw T_Fail.testFailMsg("decryption did not yield the same clear text");
+
+	}
+
+	// see if 2 byte arrays are identical
+	protected boolean byteArrayIdentical(byte[] compare, byte[] original,
+									  int offset, int length)
+	{
+		for (int i = 0; i < length; i++)
+		{
+			if (compare[i] != original[offset+i])
+				return false;
+		}
+		return true;
+	}
+
+
+    /*
+    private void testBlowfish()
+    {
+        System.out.println("Running testBlowfish");
+        try
+        {
+            // set up the provider
+            java.security.Provider sunJce = new com.sun.crypto.provider.SunJCE();
+            java.security.Security.addProvider(sunJce);
+
+            // String key = "Paula bla la da trish123 sdkfs;ldkg;sa'jlskjgklad";
+            String key = "Paulabla123456789012345";
+            byte[] buf = key.getBytes();
+            System.out.println("key length is " + buf.length);
+            SecretKeySpec sKeySpec = new SecretKeySpec(buf,"Blowfish");
+            // SecretKeySpec sKeySpec = new SecretKeySpec(buf,"DESede");
+
+            Cipher cipher = Cipher.getInstance("Blowfish/CBC/NoPadding");
+            // Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding");
+            // Cipher cipher = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
+            cipher.init(Cipher.ENCRYPT_MODE,sKeySpec);
+            // only works with NoPadding if size is a multiple of 8 bytes
+            // with PKCS5Padding, works for all sizes
+            byte[] original = "This is what should get encrypte".getBytes();
+            System.out.println("original length is " + original.length);
+            byte[] encrypted = cipher.doFinal(original);
+            // works
+            // AlgorithmParameters algParam = cipher.getParameters();
+            byte[] iv = cipher.getIV();
+            System.out.println("length of iv is " + iv.length);
+
+            Cipher cipher2 = Cipher.getInstance("Blowfish/CBC/NoPadding");
+            // Cipher cipher2 = Cipher.getInstance("DESede/CBC/NoPadding");
+            // Cipher cipher2 = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
+
+            // works
+            // cipher2.init(Cipher.DECRYPT_MODE,sKeySpec,algParam);
+            IvParameterSpec ivClass = new IvParameterSpec(iv);
+            cipher2.init(Cipher.DECRYPT_MODE,sKeySpec,ivClass);
+            byte[] decrypted = cipher2.doFinal(encrypted);
+
+            if (byteArrayIdentical(original,decrypted,0,original.length))
+                System.out.println("PASSED");
+            else
+                System.out.println("FAILED");
+
+            System.out.println("original length is " + original.length);
+            System.out.println("encrypted length is " + encrypted.length);
+            System.out.println("decrypted length is " + decrypted.length);
+        }
+        catch (Throwable t)
+        {
+            System.out.println("got an exception");
+            t.printStackTrace();
+        }
+
+        System.out.println("Finished testBlowfish");
+    }
+
+
+    private void testCryptix()
+    {
+        System.out.println("Running testCryptix");
+        try
+        {
+            // set up the provider
+            Class jceClass = Class.forName("cryptix.jce.provider.Cryptix");
+            java.security.Provider cryptixProvider = (java.security.Provider) jceClass.newInstance();
+            java.security.Security.addProvider(cryptixProvider);
+
+		    byte[] userkey = "a secret".getBytes();
+            System.out.println("userkey length is " + userkey.length);
+            Key secretKey = (Key) (new SecretKeySpec(userkey, "DES"));
+		    byte[] IV = "anivspec".getBytes();
+
+            Cipher enCipher = Cipher.getInstance("DES/CBC/NoPadding","Cryptix");
+            Cipher deCipher = Cipher.getInstance("DES/CBC/NoPadding","Cryptix");
+			IvParameterSpec ivspec = new IvParameterSpec(IV);
+
+            enCipher.init(Cipher.ENCRYPT_MODE,secretKey,ivspec);
+            deCipher.init(Cipher.DECRYPT_MODE,secretKey,ivspec);
+
+            int patternLength = 8;
+            byte[] pattern = new byte[patternLength];
+			for (int i = 0; i < patternLength; i++)
+				pattern[i] = (byte)(i & 0xFF);
+
+            byte[] cipherOutput1 = new byte[patternLength];
+            byte[] cipherOutput2 = new byte[patternLength];
+
+            int retval = 0;
+            retval = enCipher.doFinal(pattern, 0, 8, cipherOutput1, 0);
+
+            retval = deCipher.doFinal(cipherOutput1, 0, 8, cipherOutput2, 0);
+
+            if (byteArrayIdentical(cipherOutput2,pattern,0,patternLength))
+                System.out.println("PASSED TEST 1");
+            else
+                System.out.println("FAILED TEST 1");
+
+            retval = deCipher.doFinal(cipherOutput1, 0, 8, cipherOutput2, 0);
+
+            if (byteArrayIdentical(cipherOutput2,pattern,0,patternLength))
+                System.out.println("PASSED TEST 2");
+            else
+                System.out.println("FAILED TEST 2");
+        }
+        catch (Throwable t)
+        {
+            System.out.println("got an exception");
+            t.printStackTrace();
+        }
+
+        System.out.println("Finished testCryptix");
+    }
+
+
+
+    private void testMessageDigest()
+    {
+        // No provider needs to be installed for this to work.
+        try
+        {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            byte[] data = "Paulas digest".getBytes();
+            byte[] digest = md.digest(data);
+            byte[] digest2 = md.digest(data);
+            if (byteArrayIdentical(digest,digest2,0,digest.length))
+                System.out.println("PASSED");
+            else
+                System.out.println("FAILED");
+
+            System.out.println("data length is " + data.length);
+            System.out.println("digest length is " + digest.length);
+            System.out.println("digest2 length is " + digest2.length);
+        }
+        catch (Throwable t)
+        {
+            System.out.println("got an exception");
+            t.printStackTrace();
+        }
+
+        System.out.println("Finished testBlowfish");
+    }
+
+    // PT
+    private void testPCBC()
+    {
+        System.out.println("Running testPCBC");
+        try
+        {
+            // set up the provider
+            Class jceClass = Class.forName("com.sun.crypto.provider.SunJCE");
+            java.security.Provider myProvider = (java.security.Provider) jceClass.newInstance();
+            java.security.Security.addProvider(myProvider);
+            // java.security.Provider sunJce = new com.sun.crypto.provider.SunJCE();
+            // java.security.Security.addProvider(sunJce);
+
+            // String key = "Paula bla la da trish123 sdkfs;ldkg;sa'jlskjgklad";
+            String key = "PaulablaPaulablaPaulabla";
+            byte[] buf = key.getBytes();
+            System.out.println("key length is " + buf.length);
+            SecretKeySpec sKeySpec = new SecretKeySpec(buf,"DESede");
+
+            Cipher cipher = Cipher.getInstance("DESede/PCBC/NoPadding");
+            // Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding");
+            // Cipher cipher = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
+            cipher.init(Cipher.ENCRYPT_MODE,sKeySpec);
+            // only works with NoPadding if size is a multiple of 8 bytes
+            // with PKCS5Padding, works for all sizes
+            byte[] original = "This is what should get encrypte".getBytes();
+            System.out.println("original length is " + original.length);
+            byte[] encrypted = cipher.doFinal(original);
+            // works
+            // AlgorithmParameters algParam = cipher.getParameters();
+            byte[] iv = cipher.getIV();
+            System.out.println("length of iv is " + iv.length);
+
+            Cipher cipher2 = Cipher.getInstance("DESede/PCBC/NoPadding");
+            // Cipher cipher2 = Cipher.getInstance("DESede/CBC/NoPadding");
+            // Cipher cipher2 = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
+
+            // works
+            // cipher2.init(Cipher.DECRYPT_MODE,sKeySpec,algParam);
+            IvParameterSpec ivClass = new IvParameterSpec(iv);
+            cipher2.init(Cipher.DECRYPT_MODE,sKeySpec,ivClass);
+            byte[] decrypted = cipher2.doFinal(encrypted);
+
+            if (byteArrayIdentical(original,decrypted,0,original.length))
+                System.out.println("PASSED");
+            else
+                System.out.println("FAILED");
+
+            System.out.println("original length is " + original.length);
+            System.out.println("encrypted length is " + encrypted.length);
+            System.out.println("decrypted length is " + decrypted.length);
+        }
+        catch (Throwable t)
+        {
+            System.out.println("got an exception");
+            t.printStackTrace();
+        }
+
+        System.out.println("Finished testPCBC");
+    }
+
+
+    private void testPCBC2()
+    {
+        System.out.println("Running testPCBC2");
+        try
+        {
+            // set up the provider
+            Class jceClass = Class.forName("com.sun.crypto.provider.SunJCE");
+            java.security.Provider myProvider = (java.security.Provider) jceClass.newInstance();
+            java.security.Security.addProvider(myProvider);
+
+		    byte[] userkey = "a secreta secreta secret".getBytes();
+            System.out.println("userkey length is " + userkey.length);
+            Key secretKey = (Key) (new SecretKeySpec(userkey, "DESede"));
+		    byte[] IV = "anivspec".getBytes();
+
+            Cipher enCipher = Cipher.getInstance("DESede/PCBC/NoPadding","SunJCE");
+            Cipher deCipher = Cipher.getInstance("DESede/PCBC/NoPadding","SunJCE");
+			IvParameterSpec ivspec = new IvParameterSpec(IV);
+
+            enCipher.init(Cipher.ENCRYPT_MODE,secretKey,ivspec);
+            deCipher.init(Cipher.DECRYPT_MODE,secretKey,ivspec);
+
+            int patternLength = 24;
+            byte[] pattern = new byte[patternLength];
+			for (int i = 0; i < patternLength; i++)
+				pattern[i] = (byte)(i & 0xFF);
+
+            byte[] cipherOutput1 = new byte[patternLength];
+            byte[] cipherOutput2 = new byte[patternLength];
+
+            int retval = 0;
+            retval = enCipher.doFinal(pattern, 0, 24, cipherOutput1, 0);
+
+            retval = deCipher.doFinal(cipherOutput1, 0, 24, cipherOutput2, 0);
+
+            if (byteArrayIdentical(cipherOutput2,pattern,0,patternLength))
+                System.out.println("PASSED TEST 1");
+            else
+                System.out.println("FAILED TEST 1");
+
+            retval = deCipher.doFinal(cipherOutput1, 0, 24, cipherOutput2, 0);
+
+            if (byteArrayIdentical(cipherOutput2,pattern,0,patternLength))
+                System.out.println("PASSED TEST 2");
+            else
+                System.out.println("FAILED TEST 2");
+        }
+        catch (Throwable t)
+        {
+            System.out.println("got an exception");
+            t.printStackTrace();
+        }
+
+        System.out.println("Finished testPCBC2");
+    }
+
+    private void testIAIK()
+    {
+        System.out.println("Running testIAIK");
+        try
+        {
+            // set up the provider
+            Class jceClass = Class.forName("iaik.security.provider.IAIK");
+            java.security.Provider myProvider = (java.security.Provider) jceClass.newInstance();
+            java.security.Security.addProvider(myProvider);
+
+            // iaik.security.provider.IAIK.addAsProvider(true);
+
+            // iaik.utils.Util.loadClass("iaik.security.provider.IAIK",true);
+            // IAIK p=new IAIK();
+            // iaik.security.provider.IAIK.getMd5();
+
+		    byte[] userkey = "a secret".getBytes();
+            System.out.println("userkey length is " + userkey.length);
+            Key secretKey = (Key) (new SecretKeySpec(userkey, "DES"));
+		    byte[] IV = "anivspec".getBytes();
+
+            Cipher enCipher = Cipher.getInstance("DES/CBC/NoPadding","IAIK");
+            Cipher deCipher = Cipher.getInstance("DES/CBC/NoPadding","IAIK");
+			IvParameterSpec ivspec = new IvParameterSpec(IV);
+
+            enCipher.init(Cipher.ENCRYPT_MODE,secretKey,ivspec);
+            deCipher.init(Cipher.DECRYPT_MODE,secretKey,ivspec);
+
+            int patternLength = 8;
+            byte[] pattern = new byte[patternLength];
+			for (int i = 0; i < patternLength; i++)
+				pattern[i] = (byte)(i & 0xFF);
+
+            byte[] cipherOutput1 = new byte[patternLength];
+            byte[] cipherOutput2 = new byte[patternLength];
+
+            int retval = 0;
+            retval = enCipher.doFinal(pattern, 0, 8, cipherOutput1, 0);
+
+            retval = deCipher.doFinal(cipherOutput1, 0, 8, cipherOutput2, 0);
+
+            if (byteArrayIdentical(cipherOutput2,pattern,0,patternLength))
+                System.out.println("PASSED TEST 1");
+            else
+                System.out.println("FAILED TEST 1");
+
+            retval = deCipher.doFinal(cipherOutput1, 0, 8, cipherOutput2, 0);
+
+            if (byteArrayIdentical(cipherOutput2,pattern,0,patternLength))
+                System.out.println("PASSED TEST 2");
+            else
+                System.out.println("FAILED TEST 2");
+        }
+        catch (Throwable t)
+        {
+            System.out.println("got an exception");
+            t.printStackTrace();
+        }
+
+        System.out.println("Finished testIAIK");
+    }
+
+    private void printByteArray(String name, byte[] array)
+    {
+        System.out.println("printing array " + name);
+        for (int i = 0; i < array.length; i++)
+            System.out.println("index " + i + " : " + array[i]);
+    }
+    */
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_Cipher.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherBlowfish.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherBlowfish.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherBlowfish.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherBlowfish.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,38 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.crypto.T_CipherBlowfish
+
+   Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.crypto;
+
+
+/*
+	To run, put the following line in derby.properties
+	derby.module.test.T_Cipher=org.apache.derbyTesting.unitTests.crypto.T_CipherBlowfish
+
+	and run java org.apache.derbyTesting.unitTests.harness.UnitTestMain
+
+*/
+public class T_CipherBlowfish extends T_Cipher
+{
+    protected String getAlgorithm()
+    {
+        return "Blowfish/CBC/NoPadding";
+    }
+
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherBlowfish.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherCFB.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherCFB.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherCFB.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherCFB.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,37 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.crypto.T_CipherCFB
+
+   Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.crypto;
+
+/*
+	To run, put the following line in derby.properties
+	derby.module.test.T_Cipher=org.apache.derbyTesting.unitTests.crypto.T_CipherCFB
+
+	and run java org.apache.derbyTesting.unitTests.harness.UnitTestMain
+
+*/
+public class T_CipherCFB extends T_Cipher
+{
+    protected String getAlgorithm()
+    {
+        return "DESede/CFB/NoPadding";
+    }
+
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherCFB.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherDES.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherDES.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherDES.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherDES.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,37 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.crypto.T_CipherDES
+
+   Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.crypto;
+
+/*
+	To run, put the following line in derby.properties
+	derby.module.test.T_Cipher=org.apache.derbyTesting.unitTests.crypto.T_CipherDES
+
+	and run java org.apache.derbyTesting.unitTests.harness.UnitTestMain
+
+*/
+public class T_CipherDES extends T_Cipher
+{
+    protected String getAlgorithm()
+    {
+        return "DES/CBC/NoPadding";
+    }
+
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherDES.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherECB.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherECB.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherECB.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherECB.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,37 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.crypto.T_CipherECB
+
+   Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.crypto;
+
+/*
+	To run, put the following line in derby.properties
+	derby.module.test.T_Cipher=org.apache.derbyTesting.unitTests.crypto.T_CipherECB
+
+	and run java org.apache.derbyTesting.unitTests.harness.UnitTestMain
+
+*/
+public class T_CipherECB extends T_Cipher
+{
+    protected String getAlgorithm()
+    {
+        return "DESede/ECB/NoPadding";
+    }
+
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherECB.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherOFB.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherOFB.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherOFB.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherOFB.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,37 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.crypto.T_CipherOFB
+
+   Copyright 2000, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.crypto;
+
+/*
+	To run, put the following line in derby.properties
+	derby.module.test.T_Cipher=org.apache.derbyTesting.unitTests.crypto.T_CipherOFB
+
+	and run java org.apache.derbyTesting.unitTests.harness.UnitTestMain
+
+*/
+public class T_CipherOFB extends T_Cipher
+{
+    protected String getAlgorithm()
+    {
+        return "DESede/OFB/NoPadding";
+    }
+
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/crypto/T_CipherOFB.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTest.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTest.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTest.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTest.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,116 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.BasicUnitTest
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+import org.apache.derbyTesting.unitTests.harness.UnitTest;
+import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
+
+// For testing
+//import java.io.OutputStreamWriter;
+
+class BasicUnitTest implements UnitTest
+{
+	String traceMessage;
+	int testType;
+	int testDuration;
+	boolean result;
+	Error exception;
+
+	BasicUnitTest(String traceMessage,
+				  int testType,
+				  int testDuration,
+				  boolean result,
+				  Error exception){
+		this.traceMessage = traceMessage;
+		this.testType = testType;
+		this.testDuration = testDuration;
+		this.result = result;
+		this.exception = exception;
+	}
+
+	public String toString(){
+		return ("testType: "+testType+" testDuration: "+
+			testDuration+" traceMessage: "+traceMessage+
+			" result: "+result+" exception: "+exception);
+	}
+
+
+	public boolean Execute (HeaderPrintWriter output) {
+	
+		output.printlnWithHeader(toString());
+		if (exception != null)
+			throw exception;
+	
+		return result;
+	}
+
+
+
+	public int UnitTestDuration(){
+		return testDuration;
+	}
+
+	public int UnitTestType(){
+		return testType;
+	}
+
+	private void executeCatch(HeaderPrintWriter output){
+		 try{
+			 Execute(output);
+		 }
+		 catch (Error e){
+			 System.out.println("Caught exception:"+ e);
+		 }
+	}
+
+/*
+
+	public static void main(String[] Args){
+
+		OutputStreamWriter osw = new OutputStreamWriter(System.out);
+		BasicGetLogHeader glh = new BasicGetLogHeader(
+				true, true, "hi" );
+		BasicHeaderPrintWriter hpw = new BasicHeaderPrintWriter(osw,glh);
+ 
+		 
+		BasicUnitTest t1 = 
+			  new BasicUnitTest("hi Eric",1,1,true,null);
+				  
+		t1.executeCatch(hpw);
+
+		BasicUnitTest t2 = 
+			 new BasicUnitTest("hi my dear boy",1,1,true,null);
+
+		t2.executeCatch(hpw);
+
+		BasicUnitTest t3 = 
+			 new BasicUnitTest("hi my dear boy",1,1,true,
+				new Error("bogus Error"));
+
+		t3.executeCatch(hpw);
+
+		
+
+	}
+	
+*/
+}
+

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTest.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTestManager.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTestManager.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTestManager.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTestManager.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,292 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.BasicUnitTestManager
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.context.ContextService;
+import org.apache.derby.iapi.services.monitor.ModuleControl;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.monitor.Monitor;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
+import org.apache.derbyTesting.unitTests.harness.UnitTest;
+import org.apache.derbyTesting.unitTests.harness.UnitTestConstants;
+import org.apache.derbyTesting.unitTests.harness.UnitTestManager;
+import org.apache.derbyTesting.unitTests.harness.T_Bomb;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.Hashtable;
+
+public class BasicUnitTestManager implements UnitTestManager, ModuleControl
+{
+	private Vector vectorOfTests;
+	private Hashtable	namesOfTests;
+
+	private	static	boolean	alreadyRun = false;
+	private HeaderPrintWriter output;
+	private HeaderPrintWriter currentOutput;
+	private int testType = UnitTestConstants.TYPE_COMPLETE;
+	private int testDuration = UnitTestConstants.DURATION_FOREVER;
+	private boolean reportOutputOn = true;
+	private boolean performanceReportOn = false;
+	private ContextService contextService;
+	private boolean runForever = false; 
+
+	/*
+	** Constructor
+	*/
+
+	public BasicUnitTestManager() {
+	}
+
+	/*
+	** Methods of ModuleControl
+	*/
+	public void boot(boolean create, Properties startParams)
+		 throws StandardException
+	{
+		boolean	testStatus = true;
+
+		// startParams should define output, for now
+		// use the sytem trace stream. If that doesn't exist
+		// then use a null stream.
+
+		output = Monitor.getStream();
+
+		contextService = ContextService.getFactory();
+
+		this.currentOutput = output;
+
+		vectorOfTests = new Vector();
+		namesOfTests = new Hashtable();
+
+		findTests(startParams, startParams);
+		try {
+			findTests(System.getProperties(), startParams);
+		} catch (SecurityException se) {
+		}
+		findTests(Monitor.getMonitor().getApplicationProperties(), startParams);
+
+		if ( !alreadyRun )
+		{
+			testStatus = runTests();
+			alreadyRun = true;
+		}
+
+		if (!testStatus) {
+
+			// try to print out that the shutdown is occurring.
+			System.out.println("Shutting down due to unit test failure.");
+			output.printlnWithHeader("Shutting down due to unit test failure, see log for more information.");
+
+			Monitor.getMonitor().shutdown();
+		}
+	}
+
+	public void stop(){
+		return;
+	}
+
+	public synchronized void registerTest(UnitTest objectToTest, String testName){
+
+		// only add the new test if it isn't already there.
+		// otherwise you will upset me.
+		if ( !namesOfTests.containsKey( testName ) )
+		{
+			vectorOfTests.addElement(objectToTest);
+			namesOfTests.put( testName, testName );
+		}
+	}
+
+	private void findTests(Properties testList, Properties startParams) {
+
+		if (testList == null)
+			return;
+
+		for (Enumeration e = testList.propertyNames(); e.hasMoreElements(); ) {
+
+			String key = (String) e.nextElement();
+			if (key.startsWith("derby.module.test.")) {
+				String unitTestClass = testList.getProperty(key);
+
+				try {
+					Object unitTest =
+						Monitor.bootServiceModule(false, this, unitTestClass,
+												  startParams);
+					if (unitTest instanceof UnitTest) {
+						registerTest((UnitTest) unitTest, unitTestClass);
+					} else if (unitTest != null) {
+					System.out.println("class does not implement UnitTest " +
+									   unitTestClass);
+					}
+				} catch (StandardException se) {
+					System.out.println("exception booting " + unitTestClass);
+					System.out.println(se.toString());
+					se.printStackTrace(System.out);
+				}
+			}
+		}
+	}
+
+	/**
+	 *	emitAMessage
+	 *
+	 *	Convenience routine to emit messages. This routine only works
+	 *  for messages provided by this package.
+	 *
+	 *  @see	UnitTestConstants for supported durations.
+	 **/
+	private void emitAMessage(String message){
+
+	   currentOutput.printlnWithHeader(message);
+	}
+
+	private boolean runATest(UnitTest aTest){
+
+		boolean result;
+
+		String thisTestName = aTest.getClass().getName();
+		Date startTime = null, endTime;
+
+		// push a new context manager
+		ContextManager cm = null;
+		if (contextService != null) {
+			cm = contextService.newContextManager();
+			contextService.setCurrentContextManager(cm);
+		}
+
+		if (performanceReportOn)
+			startTime = new Date();
+
+		try{
+			emitAMessage("Starting test  '" + thisTestName + "'.");
+			result = aTest.Execute(currentOutput);
+			if (result == true)
+				emitAMessage("Test '" + thisTestName + "' passed");
+			else
+				emitAMessage("Test '" + thisTestName + "' failed");
+
+		} catch (Throwable t) {
+			if (t instanceof ThreadDeath)
+			{
+				t.printStackTrace(output.getPrintWriter());
+				Runtime.getRuntime().exit(1);
+			}
+
+			result = false;
+			String  msg = t.getMessage();
+			if (msg == null) msg = t.getClass().getName();
+			emitAMessage("Test '" + thisTestName + "' failed with exception '" + msg +"'.");
+			t.printStackTrace(output.getPrintWriter());
+		} finally {
+
+			if (contextService != null) {
+				//
+				//Assure the completed test does not stick around
+				//cm.cleanupOnError
+				//	(BasicUnitTestDatabaseException.cleanUp());
+				contextService.resetCurrentContextManager(cm);
+			}
+		}
+
+		if (performanceReportOn){
+			endTime = new Date();
+			emitAMessage("Test '" + thisTestName + "' took " + new Long(endTime.getTime() - startTime.getTime()) + " milliseconds.");
+		}
+
+		return result;
+	}
+
+	// STUB: Verify its ok this is synchronized.
+	public synchronized boolean runTests(){
+
+		boolean result = true;
+		int passCount = 0;
+		int failCount = 0;
+		int skipCount = 0;
+		boolean runTests = true;
+
+		if (SanityManager.DEBUG)
+		{
+			runTests =
+				!SanityManager.DEBUG_ON(UnitTestManager.SKIP_UNIT_TESTS);
+			runForever =
+				SanityManager.DEBUG_ON(UnitTestManager.RUN_FOREVER);
+		}
+		if (runTests) {
+
+		if (!runForever) T_Bomb.makeBomb();
+		for(int ix = vectorOfTests.size() - 1; ix >= 0 ; ix--){
+
+			UnitTest thisTest =
+				((UnitTest)vectorOfTests.elementAt(ix));
+			if (thisTest.UnitTestDuration() <= this.testDuration &&
+				thisTest.UnitTestType() <= this.testType){
+				if (runATest(thisTest))
+					passCount++;
+				else
+					failCount++;
+				vectorOfTests.removeElementAt(ix);
+			}
+			else{
+				skipCount++;
+			}
+		}
+		emitAMessage("Test Summary - Run " + (passCount+failCount) +
+			", Passed " + passCount + ", Failed " + failCount + ", Skipped " + skipCount + ".");
+		}
+		else {
+			emitAMessage("Tests not run.");
+		}
+		return (failCount == 0);
+	}
+
+
+	public boolean runTests(int testType, int testDuration){
+		//STUB: Sanity check for type/duration
+		this.testType = testType;
+		this.testDuration = testDuration;
+		return runTests();
+	}
+
+
+	public void setTestDuration(int testDuration){
+		//STUB: Sanity check for type/duration
+		this.testDuration = testDuration;
+		return;
+	}
+
+
+	public void setTestType(int testType){
+		//STUB: Sanity check for type/duration
+		this.testType = testType;
+		return;
+	}
+
+
+	public void setPerformanceReportOn(boolean performanceReportOn){
+		this.performanceReportOn = performanceReportOn;
+		return;
+	}	
+}
+

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/BasicUnitTestManager.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bomb.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bomb.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bomb.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bomb.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,151 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.T_Bomb
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+import org.apache.derby.iapi.services.property.PropertyUtil;
+import org.apache.derby.iapi.services.context.ContextService;
+import org.apache.derby.iapi.services.monitor.Monitor;
+
+import org.apache.derby.iapi.services.context.Context;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class T_Bomb implements Runnable { 
+	public static String BOMB_DELAY_PN="derby.testing.BombDelay";
+	private static int DEFAULT_BOMB_DELAY=3600000; //1 hour
+
+	private static T_Bomb me;
+	
+	private Thread t;
+	private Vector v;
+	private long delay;
+	private boolean armed = false;
+
+	private T_Bomb()
+	{
+		delay =
+			PropertyUtil.getSystemInt(BOMB_DELAY_PN,0,
+									  Integer.MAX_VALUE,
+									  DEFAULT_BOMB_DELAY);
+		v = new Vector();
+		t = new Thread(this);
+		t.setDaemon(true);
+		t.start();
+	}
+
+	/**
+	  Make an armed bomb set to go off in 1 hour.
+	  */
+	public synchronized static void makeBomb() {
+		if (me==null) me = new T_Bomb();
+		me.armBomb();
+	}
+
+	/**
+	  Arm a bomb to go off. If the bomb does not exist
+	  make it.
+	  */
+	public synchronized void armBomb() {
+		if (me == null) me = new T_Bomb();
+		me.armed = true;
+	}
+
+	/**
+	  Cause a bomb to explode. If the bomb does not exist
+	  make it.
+	  */
+	public synchronized static void explodeBomb() {
+		if (me == null) me = new T_Bomb();
+		me.armed = true;
+		me.blowUp();
+	}
+
+	public synchronized static void registerBombable(T_Bombable b)
+	{
+		if (me == null) me = new T_Bomb();
+		me.v.addElement(b);
+	}
+
+	public synchronized static void unRegisterBombable(T_Bombable b)
+	{
+		if (null == me || null == b )
+            return;
+        me.v.removeElement(b);
+        if( me.v.isEmpty())
+        {
+            me.armed = false;
+            me.t.interrupt();
+            me = null;
+        }
+	}
+
+	public void run() {
+
+		try {
+			Thread.sleep(delay);
+		}
+
+		catch (InterruptedException e) {
+		}
+
+		if (armed)
+		{
+			me.blowUp();
+		}
+	}
+
+	private void blowUp()
+	{
+			performLastGasp();
+			ContextService csf = ContextService.getFactory();
+			if (csf != null)
+			{
+				System.out.println("ran out of time");
+				csf.notifyAllActiveThreads
+					((Context) null);
+			}
+
+			try {
+				Thread.currentThread().sleep(30*1000); //Give threads 30 sec to shut down.
+			}
+			catch (InterruptedException ie) {}
+			System.out.println("Exit due to time bomb");
+			Runtime.getRuntime().exit(1234);
+	}
+
+	private void performLastGasp()
+	{
+		for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
+			try{
+             T_Bombable b = (T_Bombable)e.nextElement();
+			 b.lastChance();
+			}
+
+
+			catch (Exception exc) {
+				System.out.println("Last Gasp exception");
+				exc.printStackTrace();
+			}
+		} //end for
+
+	}
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bomb.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bombable.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bombable.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bombable.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bombable.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,28 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.T_Bombable
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+import org.apache.derby.iapi.error.StandardException;
+
+public interface T_Bombable
+{ 
+	public void lastChance() throws StandardException;
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Bombable.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Fail.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Fail.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Fail.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Fail.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,125 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.T_Fail
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+/**
+	Exception used to throw for errors in a unit test.
+*/
+public class T_Fail extends Exception  {
+
+	private Throwable nested;
+
+	/**
+	  Create a T_Fail exception which carries a message.
+
+	  @param messageId An Id for an error message for this exception.
+	  */
+	private T_Fail(String message) {
+		super(message);
+	}
+
+	/**
+		return a T_Fail exception to indicate the configuration does
+		not specify the module to test.
+
+		@return The exception.
+	*/
+	public static T_Fail moduleToTestIdNotFound()
+	{
+		return new T_Fail("Test failed because the configuration does not include the MODULE_TO_TEST_IDENT attribute.");
+	}
+
+	/**
+		return a T_Fail exception to indicate the configuration does
+		not contain the module to test.
+
+		@return The exception.
+	*/
+	public static T_Fail moduleToTestNotFound(String moduleToTest)
+	{
+		return new T_Fail("Test failed due to failure loading " + moduleToTest);
+	}
+
+	/**
+	  return a T_Fail exception to indicate the test failed due
+	  to an exception.
+
+	  <P>Note: Since the Test Service catches all exceptions this
+	  seems to be of limited value.
+
+	  @return The exception.
+	*/
+	public static T_Fail exceptionFail(Throwable e)
+	{
+		T_Fail tf = new T_Fail("The test failed with an exception: " + e.toString());
+		tf.nested = e;
+		return tf;
+	}
+
+	/**
+	  return a T_Fail exception to indicate the test failed.
+
+	  @return the exception.
+	  */
+	public static T_Fail testFail()
+	{
+		return new T_Fail("The test failed");
+	}
+
+	/**
+	  return a T_Fail exception which includes a user message indicating
+	  why a test failed.
+
+	  @return The exception.
+	*/
+	public static T_Fail testFailMsg(String message)
+	{
+		return new T_Fail("Test failed - " + message);
+	}
+
+	/**
+	  Check a test condition. If it is false, throw a T_Fail exception.
+
+	  @param mustBeTrue The condition.
+	  @exception T_Fail A test failure exception
+	  */
+	public static final void T_ASSERT(boolean mustBeTrue)
+		 throws T_Fail
+	{
+		if (!mustBeTrue)
+			throw testFail();
+	}
+
+	/**
+	  Check a test condition. If it is false, throw a T_Fail exception which
+	  includes a message.
+
+	  @param mustBeTrue The condition.
+	  @param msg A message describing the failue.
+	  @exception T_Fail A test failure exception
+	  */
+	public static final void T_ASSERT(boolean mustBeTrue,String msg)
+		 throws T_Fail
+	{
+		if (!mustBeTrue)
+			throw testFailMsg(msg);
+	}
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Fail.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Generic.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Generic.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Generic.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Generic.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,219 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.T_Generic
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+import org.apache.derby.iapi.services.monitor.ModuleControl;
+import org.apache.derby.iapi.services.monitor.Monitor;
+
+import org.apache.derbyTesting.unitTests.harness.UnitTest;
+import org.apache.derbyTesting.unitTests.harness.UnitTestConstants;
+import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.util.Properties;
+
+/**
+	Abstract class which executes a unit test.
+
+	<P>To write a test,	extend this class with a class which implements the two
+	abstract methods:
+<UL>	
+    <LI>runTests
+	<LI>setUp
+</UL>
+	@see UnitTest
+	@see ModuleControl
+*/
+public abstract class T_Generic implements UnitTest, ModuleControl
+{
+	/**
+	  The unqualified name for the module to test. This is set by the generic
+	  code.
+	  */
+	protected String shortModuleToTestName;
+
+	/**
+	  The start parameters for your test. This is set by generic code.
+	  */
+	protected Properties startParams;
+
+	/**
+	  The HeaderPrintWriter for test output. This is set by the
+	  generic code.
+	  */
+	protected HeaderPrintWriter out;
+
+	protected T_Generic()
+	{
+	}
+
+	/*
+	** Public methods of ModuleControl
+	*/
+
+	/**
+	  ModuleControl.start
+	  
+	  @see ModuleControl#boot
+	  @exception StandardException Module cannot be started.
+	  */
+	public void boot(boolean create, Properties startParams)
+		 throws StandardException
+	{
+		shortModuleToTestName =
+			getModuleToTestProtocolName()
+			.substring(getModuleToTestProtocolName().lastIndexOf('.')+1);
+
+		this.startParams = startParams;
+	}
+
+	/**
+	  ModuleControl.stop
+	  
+	  @see ModuleControl#stop
+	  */
+	public void stop() {
+	}
+
+	/*
+	** Public methods of UnitTest
+	*/
+	/**
+	  UnitTest.Execute
+	  
+	  @see UnitTest#Execute
+	  */
+	public boolean Execute(HeaderPrintWriter out)
+	{
+		this.out = out;
+
+		String myClass = this.getClass().getName();
+		String testName = myClass.substring(myClass.lastIndexOf('.') + 1);
+
+		System.out.println("-- Unit Test " + testName + " starting");
+
+		try
+		{
+			runTests();
+		}
+		
+		catch (Throwable t)
+		{
+			
+			while (t != null) {
+				FAIL(t.toString());
+				t.printStackTrace(out.getPrintWriter());
+				if (t instanceof StandardException) {
+					t = ((StandardException) t).getNestedException();
+					continue;
+				}
+				break;
+			}
+			return false;
+		}
+
+		System.out.println("-- Unit Test " + testName + " finished");
+
+		return true;
+	}
+
+	/**
+	  UnitTest.UnitTestDuration
+	  
+	  @return UnitTestConstants.DURATION_MICRO
+	  @see UnitTest#UnitTestDuration
+	  @see UnitTestConstants
+	  */
+	public int UnitTestDuration() {
+		return UnitTestConstants.DURATION_MICRO;
+	}
+
+	/**
+	  UnitTest.UnitTestType
+	  
+	  @return UnitTestConstants.TYPE_COMMON
+	  @see UnitTest#UnitTestType
+	  @see UnitTestConstants
+	  */
+	public int UnitTestType() {
+		return UnitTestConstants.TYPE_COMMON;
+	}
+
+	/**
+	  Emit a message indicating why the test failed.
+
+	  RESOLVE: Should this be localized?
+
+	  @param msg the message.
+	  @return false
+	*/
+	protected boolean FAIL(String msg) {
+		out.println("[" + Thread.currentThread().getName() + "] FAIL - " + msg);
+		return false;
+	}
+
+	/**
+	  Emit a message saying the test passed.
+	  You may use this to emit messages indicating individual test cases
+	  within a unit test passed.
+
+	  <P>RESOLVE:Localize this.
+	  @param test the test which passed.
+	  @return true
+	  */
+	protected boolean PASS(String testName) {
+		out.println("[" + Thread.currentThread().getName() + "] Pass - "+shortModuleToTestName +" " + testName);
+		return true;
+	}
+
+	/**
+		Emit a message during a unit test run, indent the message
+		to allow the PASS/FAIL messages to stand out.
+	*/
+	public void REPORT(String msg) {
+		out.println("[" + Thread.currentThread().getName() + "]     " + msg);
+	}
+
+	
+	/**
+	  Abstract methods to implement for your test.
+	  */
+	
+	/**
+	  Run the test. The test should raise an exception if it
+	  fails. runTests should return if the tests pass.
+
+	  @exception Exception Test code throws these
+	  */
+	protected abstract void runTests() throws Exception;
+
+	/**
+	  Get the name of the protocol for the module to test.
+	  This is the 'factory.MODULE' variable.
+	  
+	  'moduleName' to the name of the module to test. 
+
+	  @param testConfiguration the configuration for this test.
+	  */
+	protected abstract String getModuleToTestProtocolName();
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_Generic.java
------------------------------------------------------------------------------
    snv:eol-style = native

Added: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_MultiIterations.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_MultiIterations.java?view=auto&rev=155990
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_MultiIterations.java (added)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_MultiIterations.java Wed Mar  2 17:30:05 2005
@@ -0,0 +1,126 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.unitTests.harness.T_MultiIterations
+
+   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.unitTests.harness;
+
+import org.apache.derby.iapi.services.monitor.Monitor;
+import org.apache.derby.iapi.services.property.PropertyUtil;
+
+import java.util.Properties;
+
+/**
+	Abstract class which executes T_Generic. This splits the running
+	of a test into two parts, the test setup and running the test.
+	This allows the setup to be performed once, and then the
+	test itself to be run for a number of iterations. The number
+	iterations is set by the property derby.unittests.iterations
+	and defaults to 1.
+	<P>
+	Statistics are provided about each iteration in the error log. The statistics
+	are time for each iteration, used and total memory changes per iteration.
+
+	@see T_Generic
+*/
+public abstract class T_MultiIterations extends T_Generic
+{
+	protected T_MultiIterations()
+	{
+		super();
+	}
+
+	/*
+	** methods required by T_Generic
+	*/
+
+	
+	/**
+	  Run the test. The test should raise an exception if it
+	  fails. runTests should return if the tests pass.
+
+	  @exception T_Fail Test code throws these
+	  */
+	protected void runTests() throws T_Fail {
+
+		setupTest();
+
+		int	iterations = 1;
+
+		/*
+		** The property name for the number of iterations is
+		** derby.className.iterations.  For example, if the test
+		** class is derby.com.package.to.test.T_Tester,
+		** the property name is derby.T_Tester.iterations.
+		*/
+		String myClass = this.getClass().getName();
+		String noPackage = myClass.substring(myClass.lastIndexOf('.') + 1);
+		String propertyName = "derby." + noPackage + ".iterations";
+
+		String iter = PropertyUtil.getSystemProperty(propertyName);
+		if (iter != null) {
+			try {
+				iterations = Integer.parseInt(iter);
+			} catch (NumberFormatException nfe) {
+				// leave at one
+			}
+			if (iterations <= 0)
+				iterations = 1;
+		}
+
+		for (int i = 0; i < iterations; i++) {
+			Runtime.getRuntime().gc();
+			long btm = Runtime.getRuntime().totalMemory();
+			long bfm = Runtime.getRuntime().freeMemory();
+			long bum = btm - bfm;
+
+			long start = System. currentTimeMillis();
+
+			runTestSet();
+
+			long end = System. currentTimeMillis();
+
+			Runtime.getRuntime().gc();
+			long atm = Runtime.getRuntime().totalMemory();
+			long afm = Runtime.getRuntime().freeMemory();
+			long aum = atm - afm;
+
+			out.println("Iteration " + i + " took " + (end - start) + "ms");
+			out.println("Total memory increased by " + (atm - btm) + " is " + atm);
+			out.println("Used  memory increased by " + (aum - bum) + " is " + aum);
+		}
+	}
+
+	/*
+	**	  Abstract methods to implement for your test.
+	*/
+
+	/**
+		Run once to set up the test.
+
+        @exception T_Fail Test code throws these
+	*/
+	protected abstract void setupTest() throws T_Fail;
+
+	/**
+		Run once per-iteration to run the actual test.
+
+        @exception T_Fail Test code throws these
+	*/
+	protected abstract void runTestSet() throws T_Fail;
+}

Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/harness/T_MultiIterations.java
------------------------------------------------------------------------------
    snv:eol-style = native



Mime
View raw message