db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r330103 [2/2] - in /db/derby/code/trunk: ./ java/build/org/apache/derbyBuild/ java/testing/ java/testing/org/apache/derbyTesting/functionTests/harness/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derby...
Date Tue, 01 Nov 2005 18:11:23 GMT
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java?rev=330103&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java
Tue Nov  1 10:10:31 2005
@@ -0,0 +1,128 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.util
+
+Copyright 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.
+
+*/
+
+/**
+ * <p>
+ * This class factors out utility methods (including assertion machinery)
+ * for re-use by Derby JUnit tests.
+ * </p>
+ *
+ * @author Rick
+ */
+
+package org.apache.derbyTesting.functionTests.util;
+
+import junit.framework.*;
+
+public	class	DerbyJUnitTest	extends	TestCase
+{
+	/////////////////////////////////////////////////////////////
+	//
+	//	CONSTANTS
+	//
+	/////////////////////////////////////////////////////////////
+
+	/////////////////////////////////////////////////////////////
+	//
+	//	STATE
+	//
+	/////////////////////////////////////////////////////////////
+
+	/////////////////////////////////////////////////////////////
+	//
+	//	CONSTRUCTOR
+	//
+	/////////////////////////////////////////////////////////////
+	
+	public	DerbyJUnitTest() {}
+
+	/////////////////////////////////////////////////////////////
+	//
+	//	EXTRA ASSERTIONS
+	//
+	/////////////////////////////////////////////////////////////
+
+	/**
+	 * <p>
+	 * Compare two objects, allowing nulls to be equal.
+	 * </p>
+	 */
+	public	void	compareObjects( String message, Object left, Object right )
+		throws Exception
+	{
+		if ( left == null )
+		{
+			assertNull( message, right );
+		}
+		else
+		{
+			assertNotNull( right );
+
+			if ( left instanceof byte[] ) { compareBytes( message, left, right ); }
+			else if ( left instanceof java.util.Date ) { compareDates( message, left, right ); }
+			else { assertTrue( message, left.equals( right ) ); }
+		}
+	}
+
+	/**
+	 * <p>
+	 * Compare two byte arrays, allowing nulls to be equal.
+	 * </p>
+	 */
+	public	void	compareBytes( String message, Object left, Object right )
+		throws Exception
+	{
+		if ( left == null )	{ assertNull( message, right ); }
+		else { assertNotNull( right ); }
+
+		if ( !(left instanceof byte[] ) ) { fail( message ); }
+		if ( !(right instanceof byte[] ) ) { fail( message ); }
+
+		byte[]	leftBytes = (byte[]) left;
+		byte[]	rightBytes = (byte[]) right;
+		int		count = leftBytes.length;
+
+		assertEquals( message, count, rightBytes.length );
+		
+		for ( int i = 0; i < count; i++ )
+		{
+			assertEquals( message + "[ " + i + " ]", leftBytes[ i ], rightBytes[ i ] );
+		}
+	}
+	
+	/**
+	 * <p>
+	 * Compare two Dates, allowing nulls to be equal.
+	 * </p>
+	 */
+	public	void	compareDates( String message, Object left, Object right )
+		throws Exception
+	{
+		if ( left == null )	{ assertNull( message, right ); }
+		else { assertNotNull( right ); }
+
+		if ( !(left instanceof java.util.Date ) ) { fail( message ); }
+		if ( !(right instanceof java.util.Date ) ) { fail( message ); }
+
+		assertEquals( message, left.toString(), right.toString() );
+	}
+	
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/DerbyJUnitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml?rev=330103&r1=330102&r2=330103&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
Tue Nov  1 10:10:31 2005
@@ -39,6 +39,7 @@
       destdir="${out.dir}">
       <classpath>
         <pathelement path="${java13compile.classpath}"/>
+		<pathelement path="${junit}"/>
       </classpath>
       <include name="${this.dir}/VTIClasses/ExternalTable.java"/> 
     </javac>
@@ -56,6 +57,7 @@
       <classpath>
         <pathelement location="${oro}"/>
         <pathelement path="${compile.classpath}"/>
+		<pathelement path="${junit}"/>
       </classpath>
       <include name="${this.dir}/*.java"/> 
       <include name="${this.dir}/StaticInitializers/*.java"/> 

Modified: db/derby/code/trunk/tools/ant/properties/extrapath.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/ant/properties/extrapath.properties?rev=330103&r1=330102&r2=330103&view=diff
==============================================================================
--- db/derby/code/trunk/tools/ant/properties/extrapath.properties (original)
+++ db/derby/code/trunk/tools/ant/properties/extrapath.properties Tue Nov  1 10:10:31 2005
@@ -11,6 +11,7 @@
 xml-apis=${javatools.dir}/xslt4j-2_5_0/xml-apis.jar
 xalan=${javatools.dir}/xslt4j-2_5_0/xalan.jar
 javacc=${javatools.dir}/javacc.jar
+junit=${javatools.dir}/junit.jar
 
 #
 # Compile-time extras



Mime
View raw message