db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o..@apache.org
Subject svn commit: r895582 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/replicationTests/ junit/
Date Mon, 04 Jan 2010 09:03:37 GMT
Author: ole
Date: Mon Jan  4 09:03:36 2010
New Revision: 895582

URL: http://svn.apache.org/viewvc?rev=895582&view=rev
Log:
DERBY-4417 - Enable distributed replication testing - master server, slave server and test
client running on different hosts.

Committed  DERBY-4417_P2_p1.diff.txt

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest_Verify.java
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ServerSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java?rev=895582&r1=895581&r2=895582&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java
Mon Jan  4 09:03:36 2010
@@ -113,6 +113,8 @@
                 slaveReplPort,
                 testClientHost);
         
+        // Allow the slave to reach the required state before attempting to start master:
+        util.sleep(sleepTime, "Before startMaster");  // startMaster_ij should retry connection?

         startMaster(jvmVersion, replicatedDb,
                 masterServerHost, // Where the startMaster command must be given
                 masterServerPort, // master server interface accepting client requests
@@ -165,14 +167,18 @@
     throws IOException
     {
         
-        System.out.println("*** Properties -----------------------------------------");
+        util.DEBUG("*** Properties -----------------------------------------");
         userDir = System.getProperty("user.dir");
-        System.out.println("user.dir:          " + userDir);
+        util.DEBUG("user.dir:          " + userDir);
         
-        System.out.println("derby.system.home: " + System.getProperty("derby.system.home"));
+        userHome = System.getProperty("user.home");
+        util.DEBUG("user.home:          " + userHome);
+        util.writeToFile("exit;", userHome+FS+"ij_dummy_script.sql");
+        
+        util.DEBUG("derby.system.home: " + System.getProperty("derby.system.home"));
         
         String realPropertyFile = REPLICATIONTEST_PROPFILE; // Is just the plain file name
in ${user.dir}
-        System.out.println("realPropertyFile: " + realPropertyFile);
+        util.DEBUG("realPropertyFile: " + realPropertyFile);
         
         InputStream isCp =  new FileInputStream(userDir + FS + realPropertyFile);
         Properties cp = new Properties();
@@ -182,108 +188,124 @@
         // Now we can get the derby jar path, jvm path etc.
         
         util.printDebug = cp.getProperty("test.printDebug","false").equalsIgnoreCase("true");
-        System.out.println("printDebug: " + util.printDebug);
+        util.DEBUG("printDebug: " + util.printDebug);
         
         showSysinfo = cp.getProperty("test.showSysinfo","false").equalsIgnoreCase("true");
-        System.out.println("showSysinfo: " + showSysinfo);
+        util.DEBUG("showSysinfo: " + showSysinfo);
         
-        testUser = cp.getProperty("test.testUser","false");
-        System.out.println("testUser: " + testUser);
+        testUser = cp.getProperty("test.testUser","UNKNOWN");
+        util.DEBUG("testUser: " + testUser);
         
         masterServerHost = cp.getProperty("test.masterServerHost",masterServerHost);
-        System.out.println("masterServerHost: " + masterServerHost);
+        util.DEBUG("masterServerHost: " + masterServerHost);
+        cp.setProperty("test.serverHost", masterServerHost); // Set for initially running
tests against master.
         
         masterServerPort = Integer.parseInt(cp.getProperty("test.masterServerPort",""+masterServerPort));
-        System.out.println("masterServerPort: " + masterServerPort);
+        util.DEBUG("masterServerPort: " + masterServerPort);
+        cp.setProperty("test.serverPort", ""+masterServerPort); // Set for initially running
tests against master.
         
         slaveServerHost = cp.getProperty("test.slaveServerHost",slaveServerHost);
-        System.out.println("slaveServerHost: " + slaveServerHost);
+        util.DEBUG("slaveServerHost: " + slaveServerHost);
         
         slaveServerPort = Integer.parseInt(cp.getProperty("test.slaveServerPort",""+slaveServerPort));
-        System.out.println("slaveServerPort: " + slaveServerPort);
+        util.DEBUG("slaveServerPort: " + slaveServerPort);
         
         slaveReplPort = Integer.parseInt(cp.getProperty("test.slaveReplPort",""+slaveReplPort));
-        System.out.println("slaveReplPort: " + slaveReplPort);
+        util.DEBUG("slaveReplPort: " + slaveReplPort);
         
         testClientHost = cp.getProperty("test.testClientHost",testClientHost);
-        System.out.println("testClientHost: " + testClientHost);
+        util.DEBUG("testClientHost: " + testClientHost);
         
         masterDatabasePath = cp.getProperty("test.master.databasepath");
-        System.out.println("masterDatabasePath: " + masterDatabasePath);
+        util.DEBUG("masterDatabasePath: " + masterDatabasePath);
         
         slaveDatabasePath = cp.getProperty("test.slave.databasepath");
-        System.out.println("slaveDatabasePath: " + slaveDatabasePath);
+        util.DEBUG("slaveDatabasePath: " + slaveDatabasePath);
         
         replicatedDb = cp.getProperty("test.databaseName","test");
-        System.out.println("replicatedDb: " + replicatedDb);
+        util.DEBUG("replicatedDb: " + replicatedDb);
         
         bootLoad = cp.getProperty("test.bootLoad");
-        System.out.println("bootLoad: " + bootLoad);
+        util.DEBUG("bootLoad: " + bootLoad);
         
         freezeDB = cp.getProperty("test.freezeDB");
-        System.out.println("freezeDB: " + freezeDB);
+        util.DEBUG("freezeDB: " + freezeDB);
         
         unFreezeDB = cp.getProperty("test.unFreezeDB");
-        System.out.println("unFreezeDB: " + unFreezeDB);
+        util.DEBUG("unFreezeDB: " + unFreezeDB);
+        
+        simpleLoad = System.getProperty("derby.tests.replSimpleLoad", "true")
+                                                     .equalsIgnoreCase("true");
+        util.DEBUG("simpleLoad: " + simpleLoad);
+        simpleLoadTuples = Integer.parseInt(cp.getProperty("test.simpleloadtuples","10000"));
+        util.DEBUG("simpleLoadTuples: " + simpleLoadTuples);
         
         replicationTest = cp.getProperty("test.replicationTest");
-        System.out.println("replicationTest: " + replicationTest);
+        util.DEBUG("replicationTest: " + replicationTest);
         replicationVerify = cp.getProperty("test.replicationVerify");
-        System.out.println("replicationVerify: " + replicationVerify);
-        
+        util.DEBUG("replicationVerify: " + replicationVerify);
+        junitTest = cp.getProperty("test.junitTest", "true")
+                                                     .equalsIgnoreCase("true");
+        util.DEBUG("junitTest: " + junitTest);
+        
+        THREADS = Integer.parseInt(cp.getProperty("test.stressMultiThreads","0"));
+        util.DEBUG("THREADS: " + THREADS);
+        MINUTES = Integer.parseInt(cp.getProperty("test.stressMultiMinutes","0"));
+        util.DEBUG("MINUTES: " + MINUTES);
+                
         sqlLoadInit = cp.getProperty("test.sqlLoadInit");
-        System.out.println("sqlLoadInit: " + sqlLoadInit);
+        util.DEBUG("sqlLoadInit: " + sqlLoadInit);
 
         
         specialTestingJar = cp.getProperty("test.derbyTestingJar", null);
-        System.out.println("specialTestingJar: " + specialTestingJar);
+        util.DEBUG("specialTestingJar: " + specialTestingJar);
         
         jvmVersion = cp.getProperty("jvm.version");
-        System.out.println("jvmVersion: " + jvmVersion);
+        util.DEBUG("jvmVersion: " + jvmVersion);
         
         masterJvmVersion = cp.getProperty("jvm.masterversion");
         if ( masterJvmVersion == null )
         {masterJvmVersion = jvmVersion;}
-        System.out.println("masterJvmVersion: " + masterJvmVersion);
+        util.DEBUG("masterJvmVersion: " + masterJvmVersion);
         
         slaveJvmVersion = cp.getProperty("jvm.slaveversion");
         if ( slaveJvmVersion == null )
         {slaveJvmVersion = jvmVersion;}
-        System.out.println("slaveJvmVersion: " + slaveJvmVersion);
+        util.DEBUG("slaveJvmVersion: " + slaveJvmVersion);
         
         derbyVersion = cp.getProperty("derby.version");
-        System.out.println("derbyVersion: " + derbyVersion);
+        util.DEBUG("derbyVersion: " + derbyVersion);
         
         derbyMasterVersion = cp.getProperty("derby.masterversion");
         if ( derbyMasterVersion == null )
         {derbyMasterVersion = derbyVersion;}
-        System.out.println("derbyMasterVersion: " + derbyMasterVersion);
+        util.DEBUG("derbyMasterVersion: " + derbyMasterVersion);
         
         derbySlaveVersion = cp.getProperty("derby.slaveversion");
         if ( derbySlaveVersion == null )
         {derbySlaveVersion = derbyVersion;}
-        System.out.println("derbySlaveVersion: " + derbySlaveVersion);
+        util.DEBUG("derbySlaveVersion: " + derbySlaveVersion);
         
         String derbyTestingJar = derbyVersion + FS+"derbyTesting.jar";
         if ( specialTestingJar != null )  derbyTestingJar = specialTestingJar;
-        System.out.println("derbyTestingJar: " + derbyTestingJar);
+        util.DEBUG("derbyTestingJar: " + derbyTestingJar);
         
         junit_jar = cp.getProperty("junit_jar");
-        System.out.println("junit_jar: " + junit_jar);
+        util.DEBUG("junit_jar: " + junit_jar);
         
         test_jars = derbyTestingJar
                 + ":" + junit_jar
                 ;
-        System.out.println("test_jars: " + test_jars);
+        util.DEBUG("test_jars: " + test_jars);
         
         sleepTime = Integer.parseInt(cp.getProperty("test.sleepTime","15000"));
-        System.out.println("sleepTime: " + sleepTime);
+        util.DEBUG("sleepTime: " + sleepTime);
         
         runUnReplicated = cp.getProperty("test.runUnReplicated","false").equalsIgnoreCase("true");
-        System.out.println("runUnReplicated: " + runUnReplicated);
+        util.DEBUG("runUnReplicated: " + runUnReplicated);
         
         localEnv = cp.getProperty("test.localEnvironment","false").equalsIgnoreCase("true");
-        System.out.println("localEnv: " + localEnv);
+        util.DEBUG("localEnv: " + localEnv);
         
         derbyProperties = 
                  "derby.infolog.append=true"+LF
@@ -291,7 +313,7 @@
                 +"derby.drda.traceAll=true"+LF;
 
         
-        System.out.println("--------------------------------------------------------");
+        util.DEBUG("--------------------------------------------------------");
         
         masterPreRepl = new Load("masterPreRepl", cp);
         masterPostRepl = new Load("masterPostRepl", cp);
@@ -299,16 +321,18 @@
         masterPostSlave = new Load("masterPostSlave", cp);
         slavePostSlave = new Load("slavePostSlave", cp);
         
-        System.out.println("--------------------------------------------------------");
+        util.DEBUG("--------------------------------------------------------");
         // for SimplePerfTest
         tuplesToInsertPerf = Integer.parseInt(cp.getProperty("test.inserts","10000"));
+        util.DEBUG("tuplesToInsertPerf: " + tuplesToInsertPerf);
         commitFreq = Integer.parseInt(cp.getProperty("test.commitFreq","0")); // "0" is autocommit
+        util.DEBUG("commitFreq: " + commitFreq);
         
-        System.out.println("--------------------------------------------------------");
+        util.DEBUG("--------------------------------------------------------");
         
         state.initEnvironment(cp);
        
-        System.out.println("--------------------------------------------------------");
+        util.DEBUG("--------------------------------------------------------");
        
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java?rev=895582&r1=895581&r2=895582&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java
Mon Jan  4 09:03:36 2010
@@ -29,7 +29,9 @@
 import java.sql.Statement;
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import org.apache.derby.jdbc.ClientDataSource;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 public class SimplePerfTest extends BaseJDBCTestCase
@@ -40,21 +42,24 @@
         super(testcaseName);
     }
     
+    private static String dbPath = "UNDEFINED!";
+    private static String masterHostName = "UNDEFINED!";
+    private static int masterPortNo = -1;
+    
     public static Test suite()
         throws Exception
-    {
-        System.out.println("**** SimplePerfTest.suite()");
-        
-        String masterHostName = System.getProperty("test.serverHost", "localhost");
-        int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+    {        
+        masterHostName = System.getProperty("test.serverHost", "localhost");
+        masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+        dbPath = System.getProperty("test.dbPath", "wombat");
         
         TestSuite suite = new TestSuite("SimplePerfTest");
         
         tuplesToInsert = Integer.parseInt(System.getProperty("test.inserts", "1000"));
         commitFreq = Integer.parseInt(System.getProperty("test.commitFreq", "0"));
         
-        suite.addTest(SimplePerfTest.suite(masterHostName, masterPortNo));
-        System.out.println("*** Done suite.addTest(SimplePerfTest.suite())");
+        suite.addTest(SimplePerfTest.suite(masterHostName, masterPortNo, dbPath));
+        // TestSetup setup = TestConfiguration.additionalDatabaseDecorator(suite,dbPath);
         
         return (Test)suite;
     }
@@ -63,13 +68,10 @@
     /**
      * Adds this class to the *existing server* suite.
      */
-    public static Test suite(String serverHost, int serverPort)
-    {
-        System.out.println("*** SimplePerfTest.suite(serverHost,serverPort)");
-     
-        Test t = TestConfiguration.existingServerSuite(SimplePerfTest.class,false,serverHost,serverPort);
-        System.out.println("*** Done TestConfiguration.existingServerSuite(SimplePerfTest.class,false,serverHost,serverPort)");
-        return t;
+    public static Test suite(String serverHost, int serverPort, String dbPath)
+    {     
+        Test t = TestConfiguration.existingServerSuite(SimplePerfTest.class,false,serverHost,serverPort,dbPath);
+        return SecurityManagerSetup.noSecurityManager(t);
    }
     
     /**
@@ -79,24 +81,36 @@
      */
     public void testInserts()
     throws SQLException, IOException, InterruptedException
-    {
-        System.out.println("**** SimplePerfTest.testInserts() "+
-                getTestConfiguration().getJDBCClient().getJDBCDriverName());
+    {        
+        String vc = "";
+        for ( int i=0;i<20000;i++ )
+        {
+            vc = vc+"a";
+        }
         
-        Connection conn = getConnection();
+        Connection conn = clientConnection(masterHostName, masterPortNo, dbPath);
         
         Statement s = conn.createStatement();
-        s.executeUpdate("create table t (i integer primary key, vc varchar(20))");
+        try{
+        s.executeUpdate("drop table t"); // Should not be required!
+        } catch (java.sql.SQLException ignore){
+            System.out.println("'drop table t' caused: "+ignore.getMessage());
+        }
+        s.executeUpdate("create table t (i integer primary key, vc varchar(20100))");
         
-        PreparedStatement pSt = prepareStatement("insert into t values (?,?)");
+        PreparedStatement pSt = conn.prepareStatement("insert into t values (?,?)");
         
         conn.setAutoCommit(commitFreq == 0 ? true : false); // commitFreq == 0 means do autocommit
         
         for (int i=0;i<tuplesToInsert;i++)
         {
             pSt.setInt(1, i);
-            pSt.setString(2, "i"+i);
-            pSt.execute();
+            pSt.setString(2, vc+i);
+            try {pSt.execute();}
+            catch (Exception e) {
+                System.out.println("Exception when inserting: " + e.getMessage());
+                return;
+            }
             // commit after each commitFreq insert
             if ((commitFreq != 0) && ((i % commitFreq) == 0)){System.out.println("i:
"+i);conn.commit();}
         }
@@ -107,21 +121,27 @@
         rs.next();
         int count = rs.getInt(1);
         System.out.println("count: "+count);
-        // s.executeUpdate("drop table t");
     }
     public void verifyTestInserts()
     throws SQLException, IOException, InterruptedException
     {
-        System.out.println("**** SimplePerfTest.verifyTestInserts() "+
-                getTestConfiguration().getJDBCClient().getJDBCDriverName());
-        
-        Connection conn = getConnection();
+        Connection conn = clientConnection(masterHostName, masterPortNo, dbPath);
         
         Statement s = conn.createStatement();
         
         ResultSet rs = s.executeQuery("select count(*) from t");
         rs.next();
         int count = rs.getInt(1);
-        System.out.println("count: "+count);
+        // System.out.println("count: "+count);
+    }
+    private Connection clientConnection(String hostName, int portNo, String dbPath)
+            throws SQLException
+    {
+        ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+        ds.setDatabaseName(dbPath);
+        ds.setServerName(hostName);
+        ds.setPortNumber(portNo);
+        // ds.setConnectionAttributes(useEncryption(false));
+        return ds.getConnection();
     }
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest_Verify.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest_Verify.java?rev=895582&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest_Verify.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest_Verify.java
Mon Jan  4 09:03:36 2010
@@ -0,0 +1,104 @@
+/*
+ 
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.SimplePerfTest
+ 
+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.replicationTests;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derby.jdbc.ClientDataSource;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class SimplePerfTest_Verify extends BaseJDBCTestCase
+{
+    
+    public SimplePerfTest_Verify(String testcaseName)
+    {
+        super(testcaseName);
+    }
+    
+    private static String dbPath = "UNDEFINED!";
+    private static String masterHostName = "UNDEFINED!";
+    private static int masterPortNo = -1;
+    private static int tuplesToInsert = -1;
+    
+    public static Test suite()
+        throws Exception
+    {
+        masterHostName = System.getProperty("test.serverHost", "localhost");
+        masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+        dbPath = System.getProperty("test.dbPath", "wombat");
+        tuplesToInsert= Integer.parseInt(System.getProperty("test.inserts", "0"));
+        
+        TestSuite suite = new TestSuite("SimplePerfTest_Verify");
+        
+        suite.addTest(SimplePerfTest_Verify.suite(masterHostName, masterPortNo, dbPath));
+        return (Test)suite;
+    }
+
+    /**
+     * Adds this class to the *existing server* suite.
+     */
+    public static Test suite(String serverHost, int serverPort, String dbPath)
+    {
+        Test t = TestConfiguration.existingServerSuite(SimplePerfTest_Verify.class,false,serverHost,serverPort,dbPath);
+        return SecurityManagerSetup.noSecurityManager(t);
+   }
+    
+    /**
+     *
+     *
+     * @throws SQLException, IOException, InterruptedException
+     */
+    public void testVerify()
+    throws SQLException, IOException, InterruptedException
+    {
+        verifyTestInserts();
+    }
+    private void verifyTestInserts()
+    throws SQLException, IOException, InterruptedException
+    {
+        Connection conn = clientConnection(masterHostName, masterPortNo, dbPath); // getConnection();
+        
+        Statement s = conn.createStatement();
+        
+        ResultSet rs = s.executeQuery("select count(*) from t");
+        rs.next();
+        int count = rs.getInt(1);
+        this.assertEquals(count, tuplesToInsert);
+    }
+    private Connection clientConnection(String hostName, int portNo, String dbPath)
+            throws SQLException
+    {
+        ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+        ds.setDatabaseName(dbPath);
+        ds.setServerName(hostName);
+        ds.setPortNumber(portNo);
+        // ds.setConnectionAttributes(useEncryption(false));
+        return ds.getConnection();
+    }
+}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ServerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ServerSetup.java?rev=895582&r1=895581&r2=895582&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ServerSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ServerSetup.java Mon Jan
 4 09:03:36 2010
@@ -33,6 +33,7 @@
     private final String host;
     private final int port;
     private JDBCClient client;
+    private String dbPath;
     
     public ServerSetup(Test test, String host, int port) {
         super(test);
@@ -40,12 +41,26 @@
         this.port = port;
     }
 
+    public ServerSetup(Test test, String host, int port, String dbPath) {
+        super(test);
+        this.host = host;
+        this.port = port;
+        this.dbPath = dbPath;
+    }
+
     TestConfiguration getNewConfiguration(TestConfiguration old) {
                
         return new TestConfiguration(old,
             (client == null) ? JDBCClient.DERBYNETCLIENT : client, host, port);
     }
 
+    TestConfiguration getNewConfiguration(TestConfiguration old, String dbPath) {
+               
+        return new TestConfiguration(old,
+            (client == null) ? JDBCClient.DERBYNETCLIENT : client, host, port, 
+            dbPath);
+    }
+
     /**
      * Specify a JDBCClient to use in place of the default DERBYNETCLIENT.
      */
@@ -53,4 +68,11 @@
     {
         this.client = newClient;
     }
+    /**
+     * Specify a dbPath to use in place of the default.
+     */
+    void setDbPath(String dbPath)
+    {
+        this.dbPath = dbPath;
+    }
 }

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=895582&r1=895581&r2=895582&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
Mon Jan  4 09:03:36 2010
@@ -355,6 +355,26 @@
 
         return (suite);
     }
+    public static Test existingServerSuite(Class testClass, 
+            boolean cleanDB,
+            String hostName,
+            int portNumber,
+            String dbPath)
+    {
+         final TestSuite suite = new TestSuite(suiteName(testClass));
+         
+        if (cleanDB)
+        {
+            suite.addTest(new CleanDatabaseTestSetup(
+                    clientExistingServerSuite(testClass, hostName, portNumber, dbPath)));
+        }
+        else
+        {
+            suite.addTest(clientExistingServerSuite(testClass, hostName, portNumber, dbPath));
+        }
+
+        return (suite);
+    }
 
     /**
      * Return a Test suite that contains all the test fixtures
@@ -457,6 +477,14 @@
         return existingServerDecorator(suite, hostName, portNumber); 
                // Will not start server and does not stop it when done!.
     }
+    public static Test clientExistingServerSuite(Class testClass, 
+            String hostName, int portNumber, String dbPath)
+    {
+        TestSuite suite = new TestSuite(testClass,
+                suiteName(testClass)+":client");
+        return existingServerDecorator(suite, hostName, portNumber, dbPath); 
+               // Will not start server and does not stop it when done!.
+    }
 
     /**
      * Return a decorator for the passed in tests that sets the
@@ -563,6 +591,25 @@
         ((ServerSetup)r).setJDBCClient(JDBCClient.DERBYNETCLIENT);
         return r;
     }
+    /**
+    * A variant of defaultServerDecorator allowing 
+    * non-default hostname, portnumber and database name.
+    */
+    public static Test existingServerDecorator(Test test, 
+            String hostName, int PortNumber, String dbPath)
+    {
+    	// Need to have network server and client and not
+        // running in J2ME (JSR169).
+        if (!(Derby.hasClient() && Derby.hasServer())
+                || JDBC.vmSupportsJSR169())
+            return new TestSuite("empty: no network server support");
+
+        Test r =
+                new ServerSetup(test, hostName, PortNumber);
+        ((ServerSetup)r).setJDBCClient(JDBCClient.DERBYNETCLIENT);
+        ((ServerSetup)r).setDbPath(dbPath);
+        return r;
+    }
    
     /**
      * Decorate a test to use suite's default host and Alternative port.
@@ -1007,6 +1054,29 @@
         initConnector(copy.connector);
     }
 
+    TestConfiguration(TestConfiguration copy, JDBCClient client,
+            String hostName, int port, String dataBasePath)
+    {
+        this.defaultDbName = dataBasePath;
+        this.usedDbNames.addAll(copy.usedDbNames);        
+        logicalDbMapping.putAll(copy.logicalDbMapping);
+        this.userName = copy.userName;
+        this.userPassword = copy.userPassword;
+
+        this.isVerbose = copy.isVerbose;
+        this.doTrace = copy.doTrace;
+        this.port = port;
+        this.jmxPort = copy.jmxPort;
+        
+        this.jdbcClient = client;
+        this.hostName = hostName;
+
+        this.ssl = copy.ssl;
+        
+        this.url = createJDBCUrlWithDatabaseName(defaultDbName);
+        initConnector(copy.connector);
+    }
+
     /**
      * Obtain a new configuration identical to the passed in
      * one except for the default user and password.



Mime
View raw message