db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r599836 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/jdbcapi/ functionTests/tests/junitTests/compatibility/ junit/
Date Fri, 30 Nov 2007 14:44:20 GMT
Author: dyre
Date: Fri Nov 30 06:44:18 2007
New Revision: 599836

URL: http://svn.apache.org/viewvc?rev=599836&view=rev
Log:
DERBY-2807: Patch adds BLOB/CLOB testing to the compatibility testing
framework


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java?rev=599836&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Compat_BlobClob4BlobTest.java
Fri Nov 30 06:44:18 2007
@@ -0,0 +1,72 @@
+/*
+ *
+ * Derby - Class Compat_BlobClob4BlobTest
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.functionTests.tests.jdbcapi;
+
+import junit.framework.*;
+
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Test of JDBC blob and clob
+ * Create a test suite running BlobClob4BlobTest, but in a server-client setting 
+ * where the server has already been started.
+ */
+
+public class Compat_BlobClob4BlobTest extends BlobClob4BlobTest {
+
+    /** Creates a new instance of Compat_BlobClob4BlobTest */
+    public Compat_BlobClob4BlobTest(String name) {
+        super(name);
+    }
+
+    /**
+     * Set up the connection to the database.
+     */
+        
+    public void setUp() throws  Exception { // IS NEVER RUN!
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /***                TESTS               ***/
+
+
+    /**
+     * Run the tests of BlobClob4BlobTest in server-client on an already started server.
+     *
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Compat_BlobClob4BlobTest");
+        /* Embedded is not relevant for a running server....
+         suite.addTest(
+                TestConfiguration.embeddedSuite(BlobClob4BlobTest.class)); */
+        suite.addTest(
+                TestConfiguration.defaultExistingServerSuite(BlobClob4BlobTest.class, false));
+                
+        return (Test)suite; // Avoiding CleanDatabaseTestSetup and setLockTimeouts which
both use embedded.
+
+
+    }
+
+
+}

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java?rev=599836&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/BLOBCLOB_CompatibilitySuite.java
Fri Nov 30 06:44:18 2007
@@ -0,0 +1,143 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.compatibility.BLOBCLOB_CompatibilitySuite
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you 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 is the JUnit suite verifying compatibility of Derby clients and
+ * servers across Derby version levels and supported VMs. When you want
+ * to add a new class of tests to this suite, just add the classname to
+ * the accumulator in suite().
+ * </p>
+ *
+ */
+
+package org.apache.derbyTesting.functionTests.tests.junitTests.compatibility;
+
+import junit.framework.*;
+
+import org.apache.derbyTesting.functionTests.tests.jdbcapi.Compat_BlobClob4BlobTest;
+
+public	class	BLOBCLOB_CompatibilitySuite	extends	CompatibilitySuite
+{
+
+	/////////////////////////////////////////////////////////////
+	//
+	//	JUnit BEHAVIOR
+	//
+	/////////////////////////////////////////////////////////////
+
+	/**
+	 * <p>
+	 * JUnit boilerplate which adds as test cases all public methods
+	 * whose names start with the string "test" in the named classes.
+	 * When you want to add a new class of tests, just wire it into
+	 * this suite.
+	 * </p>
+	 */
+    public static Test suite()
+    {
+        TestSuite testSuite = new TestSuite();
+        
+        testSuite.addTest(Compat_BlobClob4BlobTest.suite()); // ONLY REAL DIFFERENCE FROM
CompatibilitySuite
+
+        return testSuite;
+    }
+
+
+	/////////////////////////////////////////////////////////////
+	//
+	//	ENTRY POINT
+	//
+	/////////////////////////////////////////////////////////////
+
+	/**
+	 * <p>
+	 * Run JDBC compatibility tests using either the specified client or
+	 * the client that is visible
+	 * on the classpath. If there is more than one client on the classpath,
+	 * exits with an error.
+	 * </p>
+	 *
+	 * <ul>
+	 * <li>arg[ 0 ] = required name of database to connect to</li>
+	 * <li>arg[ 1 ] = optional driver to use. if not specified, we'll look for a
+	 *                client on the classpath</li>
+	 * </ul>
+	 */
+	public static void main( String args[] )
+		throws Exception
+	{
+            int exitStatus = FAILURE_EXIT;
+
+            if (
+                parseDebug() &&
+                parseArgs( args ) &&
+                parseVMLevel() &&
+                findClient() &&
+                findServer()
+		)
+            {		
+                Test t = suite(); 
+                println("#      BLOBCLOB_CompatibilitySuite.main() will run suite with  "

+                    + t.countTestCases() + " testcases.");
+            
+                TestResult result = junit.textui.TestRunner.run( t );
+
+                exitStatus = result.errorCount() + result.failureCount();
+            }
+
+            Runtime.getRuntime().exit( exitStatus );
+	}
+
+	/////////////////////////////////////////////////////////////
+	//
+	//	INNER CLASSES
+	//
+	/////////////////////////////////////////////////////////////
+
+	/**
+	 * <p>
+	 * This helper class exposes an entry point for creating an empty database.
+	 * </p>
+	 */
+	public	static	final	class	Creator
+	{
+		private	static	BLOBCLOB_CompatibilitySuite	_driver = new BLOBCLOB_CompatibilitySuite();
+		
+		/**
+		 * <p>
+		 * Wait for server to come up, then create the database.
+		 * </p>
+		 *
+		 * <ul>
+		 * <li>args[ 0 ] = name of database to create.</li>
+		 * </ul>
+		 */
+		public	static	void	main( String[] args )
+			throws Exception
+		{
+			String		databaseName = args[ 0 ];
+			findClient();
+			_driver.createDB( databaseName );
+		}
+		
+	}
+
+}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java?rev=599836&r1=599835&r2=599836&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
Fri Nov 30 06:44:18 2007
@@ -134,7 +134,11 @@
 			   findServer()
 		   )
 		{		
-			TestResult	result = junit.textui.TestRunner.run( suite() );
+			Test t = suite(); 
+			println("CompatibilitySuite.main() will run suite with  " 
+				+ t.countTestCases() + " testcases.");
+
+			TestResult	result = junit.textui.TestRunner.run( t );
 			
 			exitStatus = result.errorCount() + result.failureCount();
 		}
@@ -216,7 +220,7 @@
 	// We allow for the special case when we're running the embedded client
 	// off the current compiled class tree rather than off product jars.
 	//
-	private	static	boolean	findClient()
+	static	boolean	findClient()
 		throws Exception
 	{
 		//
@@ -275,7 +279,7 @@
 	// Initialize server settings. Assumes that you have called
 	// findClient().
 	//
-	private	static	boolean	findServer()
+	static	boolean	findServer()
 		throws Exception
 	{
 		try {
@@ -299,7 +303,7 @@
 		return true;
 	}
 
-	private	static	boolean	parseVMLevel()
+	static	boolean	parseVMLevel()
 		throws Exception
 	{
 		String				vmVersion = getVMVersion();
@@ -317,7 +321,7 @@
 		return true;
 	}
 
-	private	static	boolean	parseArgs( String args[] )
+	static	boolean	parseArgs( String args[] )
 		throws Exception
 	{
 		if ( ( args == null ) || (args.length == 0 ) )
@@ -356,7 +360,7 @@
 	 * Get the vm level of the server.
 	 * </p>
 	 */
-	private	static	void	parseServerVMVersion( Connection conn )
+	static	void	parseServerVMVersion( Connection conn )
 		throws SQLException
 	{
 		dropFunction( conn, SERVER_VERSION_FUNCTION );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=599836&r1=599835&r2=599836&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Fri Nov 30 06:44:18 2007
@@ -245,6 +245,30 @@
 
         return (suite);
     }
+    /**
+     * Equivalent to "defaultSuite" as defined above, but assumes a server
+     * has already been started. 
+     * Does NOT decorate for running in embedded mode.
+     */
+    public static Test defaultExistingServerSuite(Class testClass)
+    {
+        return defaultExistingServerSuite(testClass, true);
+    }
+    public static Test defaultExistingServerSuite(Class testClass, boolean cleanDB)
+    {
+         final TestSuite suite = new TestSuite(suiteName(testClass));
+         
+        if (cleanDB)
+        {
+            suite.addTest(new CleanDatabaseTestSetup(clientExistingServerSuite(testClass)));
+        }
+        else
+        {
+            suite.addTest(clientExistingServerSuite(testClass));
+        }
+
+        return (suite);
+    }
 
     /**
      * Return a Test suite that contains all the test fixtures
@@ -320,6 +344,18 @@
     }
 
     /**
+     * Equivalent to 'clientServerSuite' above, but assumes server is
+     * already running.
+     *
+     */
+    public static Test clientExistingServerSuite(Class testClass)
+    {
+        TestSuite suite = new TestSuite(testClass,
+                suiteName(testClass)+":client");
+        return defaultExistingServerDecorator(suite); // Will not start server and does not
stop it when done!.
+    }
+
+    /**
      * Return a decorator for the passed in tests that sets the
      * configuration for the client to be Derby's JDBC client
      * and to start the network server at setUp.
@@ -345,6 +381,28 @@
         Test test = new NetworkServerTestSetup(suite, false);
             
         return defaultServerDecorator(test,port);
+    }
+    /**
+     * Decorate a test to use suite's default host and port, 
+     * but assuming the server is already running.
+     */
+    public static Test defaultExistingServerDecorator(Test test)
+    {
+        // As defaultServerDecorator but assuming 
+        // server is already started.
+        // Need to have client 
+        // and not running in J2ME (JSR169).
+        if (!(Derby.hasClient())
+                || JDBC.vmSupportsJSR169())
+        {
+            return new TestSuite("empty: no network server support in JSR169 (or derbyclient.jar
missing).");
+        }
+        
+        Test r =
+                new ServerSetup(test, DEFAULT_HOSTNAME, DEFAULT_PORT);
+        ((ServerSetup)r).setJDBCClient(JDBCClient.DERBYNETCLIENT); 
+        
+        return r;
     }
    
     /**



Mime
View raw message