db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1382791 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/compatibility/ functionTests/tests/jdbcapi/ functionTests/tests/tools/ junit/
Date Mon, 10 Sep 2012 12:17:45 GMT
Author: kahatlen
Date: Mon Sep 10 12:17:44 2012
New Revision: 1382791

URL: http://svn.apache.org/viewvc?rev=1382791&view=rev
Log:
DERBY-5917: NoClassDefFoundErrors when running tests without derbynet.jar and derbyclient.jar

Stop using client classes in XATransactionTest and CacheSessionDataTest
when running with the embedded driver.

Skip compatibility tests when client or server is not available.

Skip test case for server command in derbyrunjartest if the server
is not available.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CacheSessionDataTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/_Suite.java?rev=1382791&r1=1382790&r2=1382791&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/compatibility/_Suite.java
Mon Sep 10 12:17:44 2012
@@ -28,6 +28,7 @@ import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.Derby;
 import org.apache.derbyTesting.junit.DerbyVersion;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
 import org.apache.derbyTesting.junit.ServerSetup;
@@ -120,7 +121,11 @@ public class _Suite
         // DERBY-5889: Disabling tests on Windonws while investigating.
         if (isWindowsPlatform()) {
             return new TestSuite(
-                    "tests.compatibilty disabled on Windows, see DERBY-5889");
+                    "tests.compatibility disabled on Windows, see DERBY-5889");
+        }
+        if (!Derby.hasClient() || !Derby.hasServer()) {
+            return new TestSuite("Compatibility tests skipped because " +
+                                 "client or server is missing");
         }
         TestSuite suite = new TestSuite();
         addVersionCombinations(suite);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CacheSessionDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CacheSessionDataTest.java?rev=1382791&r1=1382790&r2=1382791&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CacheSessionDataTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CacheSessionDataTest.java
Mon Sep 10 12:17:44 2012
@@ -449,7 +449,7 @@ public class CacheSessionDataTest extend
     }
     
     private void verifyCachedSchema(Connection c) throws SQLException {
-        if (c instanceof org.apache.derby.client.am.Connection) {
+        if (usingDerbyNetClient()) {
             String cached =
                     ((org.apache.derby.client.am.Connection) c).
                     getCurrentSchemaName();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java?rev=1382791&r1=1382790&r2=1382791&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATransactionTest.java
Mon Sep 10 12:17:44 2012
@@ -21,7 +21,6 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
-import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -32,12 +31,9 @@ import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import junit.framework.Assert;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.derby.client.ClientXid;
-import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.shared.common.reference.SQLState;
 
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
@@ -118,7 +114,7 @@ public class XATransactionTest extends B
             gid[i] = (byte) i;
             bid[i] = (byte) (64 - i);
         }
-        Xid xid = new ClientXid(0x1234, gid, bid);
+        Xid xid = XATestUtil.getXid(0x1234, gid, bid);
 
         // get the stuff required to execute the global transaction
         xaConn = xaDataSource.getXAConnection();
@@ -590,8 +586,7 @@ public class XATransactionTest extends B
     static Xid createXid(int gtrid, int bqual) throws XAException {
         byte[] gid = new byte[2]; gid[0]= (byte) (gtrid % 256); gid[1]= (byte) (gtrid / 256);
         byte[] bid = new byte[2]; bid[0]= (byte) (bqual % 256); bid[1]= (byte) (bqual / 256);
-        Xid xid = new ClientXid(0x1234, gid, bid);
-        return xid;
+        return XATestUtil.getXid(0x1234, gid, bid);
     }
 
     /** Parses the xid value from the string. The format of the input string is
@@ -623,11 +618,7 @@ public class XATransactionTest extends B
             bqual[i] = (byte) Integer.parseInt(bqualS.substring(2*i, 2*i + 2), 16);
         }
 
-        // Using ClientXid is ok also for embedded driver
-        // since it does not contain any related code
-        // and there is no implementation of Xid iterface
-        // for embedded driver
-        return new ClientXid(fmtid, gtid, bqual);
+        return XATestUtil.getXid(fmtid, gtid, bqual);
     }
 
     public XATransactionTest(String name) {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java?rev=1382791&r1=1382790&r2=1382791&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest.java
Mon Sep 10 12:17:44 2012
@@ -27,6 +27,7 @@ import java.util.Arrays;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.Derby;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
 
@@ -46,9 +47,8 @@ public class derbyrunjartest extends Bas
         TestSuite suite = new TestSuite(cl);
 
         // The server command can only be used on platforms that support
-        // the network server. Specifically, it does not work in J2ME
-        // environments.
-        if (JDBC.vmSupportsJDBC3()) {
+        // the network server.
+        if (Derby.hasServer()) {
             suite.addTest(new derbyrunjartest("xtestServer"));
         }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java?rev=1382791&r1=1382790&r2=1382791&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/XATestUtil.java Mon Sep
10 12:17:44 2012
@@ -26,6 +26,7 @@ import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Arrays;
 
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.Xid;
@@ -35,8 +36,23 @@ public class XATestUtil {
     /**
      * Return a new Xid for testing.
     */
-    public static Xid getXid(int xid, int b1, int b2) {
-        return new utilXid(xid, b1, b2);
+    public static Xid getXid(int formatId, int b1, int b2) {
+        byte[] globalId = new byte[Xid.MAXGTRIDSIZE];
+        byte[] branchId = new byte[Xid.MAXBQUALSIZE];
+
+        for (int i = 0; i < globalId.length; i++) {
+            globalId[i] = (byte) (b1 + i);
+        }
+
+        for (int i = 0; i < branchId.length; i++) {
+            branchId[i] = (byte) (b2 + i);
+        }
+
+        return getXid(formatId, globalId, branchId);
+    }
+
+    public static Xid getXid(int formatId, byte[] globalId, byte[] branchId) {
+        return new utilXid(formatId, globalId, branchId);
     }
     
     /**
@@ -133,18 +149,10 @@ class utilXid implements Xid, Serializab
 
     private byte[] branch_id;
 
-    utilXid(int xid, int b1, int b2) {
-        format_id = xid;
-        global_id = new byte[Xid.MAXGTRIDSIZE];
-        branch_id = new byte[Xid.MAXBQUALSIZE];
-
-        for (int i = 0; i < global_id.length; i++) {
-            global_id[i] = (byte) (b1 + i);
-        }
-
-        for (int i = 0; i < branch_id.length; i++) {
-            branch_id[i] = (byte) (b2 + i);
-        }
+    utilXid(int format_id, byte[] global_id, byte[] branch_id) {
+        this.format_id = format_id;
+        this.global_id = global_id;
+        this.branch_id = branch_id;
     }
 
     /**
@@ -177,4 +185,25 @@ class utilXid implements Xid, Serializab
     public byte[] getBranchQualifier() {
         return (branch_id);
     }
+
+    public boolean equals(Object obj) {
+        boolean ret = false;
+
+        if (obj instanceof utilXid) {
+            utilXid that = (utilXid) obj;
+            ret = this.format_id == that.format_id &&
+                    Arrays.equals(this.global_id, that.global_id) &&
+                    Arrays.equals(this.branch_id, that.branch_id);
+        }
+
+        return ret;
+    }
+
+    public int hashCode() {
+        int hash = 7;
+        hash = 41 * hash + this.format_id;
+        hash = 41 * hash + Arrays.hashCode(this.global_id);
+        hash = 41 * hash + Arrays.hashCode(this.branch_id);
+        return hash;
+    }
 }



Mime
View raw message