db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject Re: svn commit: r777105 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/
Date Fri, 22 May 2009 16:16:05 GMT
Also noticed following failure with
testReplication_Local_3_p5_DERBY_3878 on Windows with ibm15 jvm.
1) testReplication_Local_3_p5_DERBY_3878(org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p5)junit.framework.AssertionFailedError:
Got -1 XRE11 DERBY SQL error: SQLCODE: -1, SQLSTATE: XRE11, SQLERRMC:
Could not perform operation 'stopSlave' because the database
'C:\jartest\JarResults.2009-05-21\ibm15_suites.All\db_slave\wombat'
has not been booted.. Expected XRE42
	at org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun.assertException(ReplicationRun.java:3388)
	at org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p5.testReplication_Local_3_p5_DERBY_3878(ReplicationRun_Local_3_p5.java:96)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:106)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
	at junit.extensions.TestSetup.run(TestSetup.java:23)


On Fri, May 22, 2009 at 9:11 AM, Mamta Satoor <msatoor@gmail.com> wrote:
> Hi Ole,
>
> Not sure if the following javadoc is related to your checkin but can
> you please take a look?
>
> [javadoc] C:\nightlies\main\src\opensource\java\testing\org\apache\derbyTesting\functionTests\tests\replicationTests\ReplicationRun_Local_3_p6.java:50:
> warning - Tag @param cannot be used in field documentation.  It can
> only be used in the following types of documentation: class/interface,
> constructor, method.
>
>
> thanks,
> Mamta
>
> On Thu, May 21, 2009 at 6:13 AM,  <rhillegas@apache.org> wrote:
>> Author: rhillegas
>> Date: Thu May 21 13:13:04 2009
>> New Revision: 777105
>>
>> URL: http://svn.apache.org/viewvc?rev=777105&view=rev
>> Log:
>> DERBY-3921: Committed Ole's patch adding a test for replication of encrypted databases.
>>
>> Added:
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java   (with props)
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java   (with props)
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java   (with props)
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java   (with props)
>> Modified:
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
>>    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java Thu May 21 13:13:04 2009
>> @@ -54,6 +54,10 @@
>>
>>     static String userDir = null;
>>
>> +    static String dataEncryption = null;
>> +      // Set to a legal encryption string to
>> +      // create or connect to an encrypted db.
>> +
>>     static String masterServerHost = "localhost";
>>     static int masterServerPort = 1527; // .. default..
>>     static String slaveServerHost = "localhost";
>> @@ -72,6 +76,9 @@
>>
>>     static boolean runUnReplicated = false;
>>
>> +    static boolean simpleLoad = true;
>> +    static int simpleLoadTuples = 1000;
>> +
>>     static int tuplesToInsertPerf = 10000;
>>     static int commitFreq = 0; // autocommit
>>
>> @@ -134,6 +141,8 @@
>>
>>     /** A Connection to the master database*/
>>     private Connection masterConn = null;
>> +    /** A Connection to the slave database*/
>> +    private Connection slaveConn = null;
>>     /** The exception thrown as a result of a startSlave connection attempt  */
>>     private volatile Exception startSlaveException = null;
>>
>> @@ -172,6 +181,16 @@
>>         super.tearDown();
>>     }
>>
>> +    String useEncryption(boolean create)
>> +    {
>> +        String encryptionString = "";
>> +        if ( dataEncryption != null)
>> +        {
>> +            if ( create ) encryptionString = ";dataEncryption=true";
>> +            encryptionString = encryptionString+";"+dataEncryption;
>> +        }
>> +        return encryptionString;
>> +    }
>>
>>     //////////////////////////////////////////////////////////////
>>     ////
>> @@ -207,7 +226,8 @@
>>         String serverURL = "jdbc:derby:"
>>                 +"//"+serverHost+":"+serverPort+"/";
>>         String dbURL = serverURL
>> -                +fullDbPath;
>> +                +fullDbPath
>> +                +useEncryption(false);
>>         Connection conn = null;
>>         String lastmsg = null;
>>         long sleeptime = 200L;
>> @@ -266,6 +286,7 @@
>>             ds.setDatabaseName(fullDbPath);
>>             ds.setServerName(serverHost);
>>             ds.setPortNumber(serverPort);
>> +            ds.setConnectionAttributes(useEncryption(false));
>>             Connection conn = ds.getConnection();
>>             conn.close();
>>         }
>> @@ -294,6 +315,7 @@
>>                 ds.setDatabaseName(fullDbPath);
>>                 ds.setServerName(serverHost);
>>                 ds.setPortNumber(serverPort);
>> +                ds.setConnectionAttributes(useEncryption(false));
>>                 Connection conn = ds.getConnection();
>>                 util.DEBUG("Got connection after "
>>                         + (count-1) +" * "+ sleepTime + " ms.");
>> @@ -327,6 +349,7 @@
>>                 ds.setDatabaseName(fullDbPath);
>>                 ds.setServerName(serverHost);
>>                 ds.setPortNumber(serverPort);
>> +                ds.setConnectionAttributes(useEncryption(false));
>>                 Connection conn = ds.getConnection();
>>                 // Should never get here!
>>                 conn.close();
>> @@ -370,7 +393,8 @@
>>                 +"//"+serverHost+":"+serverPort+"/";
>>         String dbURL = serverURL
>>                 +dbPath
>> -                +FS+replicatedDb;
>> +                +FS+replicatedDb
>> +                +useEncryption(false);
>>         util.DEBUG("**** DriverManager.getConnection(\"" + dbURL+";shutdown=true\");");
>>
>>         try{
>> @@ -407,11 +431,20 @@
>>                 + ") "
>>                 );
>>
>> +        if ( replicationTest == null )
>> +        {
>> +            util.DEBUG("No replicationTest specified. Exitting.");
>> +            return;
>> +        }
>> +
>> +        if ( simpleLoad )
>> +        {
>> +            _testInsertUpdateDeleteOnMaster(serverHost, serverPort,
>> +                dbName, simpleLoadTuples);
>> +            return;
>> +        }
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+serverHost
>> -                +":"+serverPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName;
>> +        String URL = masterURL(dbName);
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbyTesting.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>> @@ -424,12 +457,6 @@
>>
>>         String command = null;
>>
>> -        if ( replicationTest == null )
>> -        {
>> -            util.DEBUG("No replicationTest specified. Exitting.");
>> -            return;
>> -        }
>> -
>>         util.DEBUG("replicationTest: " + replicationTest);
>>         if ( replicationTest.indexOf(".sql") >= 0 )
>>         {
>> @@ -492,10 +519,7 @@
>>                 );
>>
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+serverHost
>> -                +":"+serverPort+"/"
>> -                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName;
>> +        String URL = slaveURL(dbName);
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbyTesting.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>> @@ -588,10 +612,7 @@
>>                 );
>>
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+masterHost
>> -                +":"+masterPort+"/"
>> -                +masterDatabasePath+ /* FS+masterDbSubPath+ */ FS+dbSubPath;
>> +        String URL = masterLoadURL(dbSubPath);
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbyTesting.jar"
>>                 // Needed for 'run resource 'createTestProcedures.subsql';' cases?
>> @@ -667,10 +688,7 @@
>>                 );
>>
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+masterHost
>> -                +":"+masterPort+"/"
>> -                +masterDatabasePath+ /* FS+masterDbSubPath+ */ FS+dbSubPath;
>> +        String URL = masterLoadURL(dbSubPath);
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbyTesting.jar"
>>                 // Needed for 'run resource 'createTestProcedures.subsql';' cases?
>> @@ -733,11 +751,9 @@
>>     {
>>         // Should just do a "connect....;create=true" here, instead of copying in initMaster.
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+masterHost
>> -                +":"+masterServerPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
>> -                +";create=true";
>> +        String URL = masterURL(dbName)
>> +                +";create=true"
>> +                +useEncryption(true);
>>
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>> @@ -748,13 +764,6 @@
>>         }
>>         String clientJvm = BaseTestCase.getJavaExecutableName();
>>
>> -        String command = clientJvm
>> -                + " -Dij.driver=" + DRIVER_CLASS_NAME
>> -                + " -Dij.connection.createMaster=\"" + URL + "\""
>> -                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
>> -                + " " + "/home/os136789/Replication/testing/exit.sql" // FIXME!!
>> -                ;
>> -
>>         String results = null;
>>         if ( masterHost.equalsIgnoreCase("localhost") || localEnv )
>>         {
>> @@ -770,6 +779,13 @@
>>         else
>>         {
>>         // Execute the ij command on the testClientHost as testUser
>> +            String command = clientJvm
>> +                + " -Dij.driver=" + DRIVER_CLASS_NAME
>> +                + " -Dij.connection.createMaster=\"" + URL + "\""
>> +                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
>> +                + " " + "exit.sql" // FIXME!!
>> +                ;
>> +
>>             results =
>>                 runUserCommandRemotely(command,
>>                 testClientHost,
>> @@ -783,10 +799,7 @@
>>         util.DEBUG("************************** DERBY-???? Preliminary needs to freeze db before copying to slave and setting replication mode.");
>>         if ( masterServerHost.equalsIgnoreCase("localhost") || localEnv )
>>         {
>> -             URL = DB_PROTOCOL
>> -                +"://"+masterServerHost
>> -                +":"+masterServerPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName;
>> +             URL = masterURL(dbName);
>>             Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
>>             util.DEBUG("bootMasterDatabase getConnection("+URL+")");
>>             Connection conn = DriverManager.getConnection(URL);
>> @@ -812,6 +825,7 @@
>>                     masterServerHost, masterServerPort,
>>                     dbSubPath+FS+dbName);
>>         }
>> +        util.DEBUG("bootMasterDatabase done.");
>>     }
>>
>>     /**
>> @@ -913,10 +927,7 @@
>>             masterClassPath = classPath;
>>         }
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+masterHost
>> -                +":"+masterServerPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
>> +        String URL = masterURL(dbName)
>>                 +";startMaster=true;slaveHost="+slaveReplInterface
>>                 +";slavePort="+slaveReplPort;
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>> @@ -952,10 +963,7 @@
>>             throws Exception
>>     {
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+masterHost
>> -                +":"+masterServerPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
>> +        String URL = masterURL(dbName)
>>                 +";startMaster=true;slaveHost="+slaveReplInterface
>>                 +";slavePort="+slaveReplPort;
>>
>> @@ -979,7 +987,8 @@
>>                     ds.setPortNumber(masterServerPort);
>>                     ds.setConnectionAttributes("startMaster=true"
>>                             +";slaveHost="+slaveReplInterface
>> -                            +";slavePort="+slaveReplPort);
>> +                            +";slavePort="+slaveReplPort
>> +                            +useEncryption(false));
>>                     conn = ds.getConnection();
>>
>>                     done = true;
>> @@ -1026,10 +1035,7 @@
>>      */
>>     protected Connection getMasterConnection() {
>>         if (masterConn == null) {
>> -            String url = DB_PROTOCOL + "://" + masterServerHost + ":" +
>> -                         masterServerPort + "/" +
>> -                         masterDatabasePath + FS + masterDbSubPath + FS +
>> -                         replicatedDb;
>> +            String url = masterURL(replicatedDb);
>>             try {
>>                 masterConn = DriverManager.getConnection(url);
>>             } catch (SQLException sqle) {
>> @@ -1038,6 +1044,22 @@
>>         }
>>         return masterConn;
>>     }
>> +
>> +    /**
>> +     * Get a connection to the slave database.
>> +     * @return A connection to the slave database
>> +     */
>> +    protected Connection getSlaveConnection() {
>> +        if (slaveConn == null) {
>> +            String url = slaveURL(replicatedDb);
>> +            try {
>> +                slaveConn = DriverManager.getConnection(url);
>> +            } catch (SQLException sqle) {
>> +                fail("Could not connect to slave database");
>> +            }
>> +        }
>> +        return slaveConn;
>> +    }
>>
>>
>>     /**
>> @@ -1053,6 +1075,18 @@
>>     }
>>
>>     /**
>> +     * Execute SQL on the slave database through a Statement
>> +     * @param sql The sql that should be executed on the slave database
>> +     * @throws java.sql.SQLException thrown if an error occured while
>> +     * executing the sql
>> +     */
>> +    protected void executeOnSlave(String sql) throws SQLException {
>> +         Statement s = getSlaveConnection().createStatement();
>> +         s.execute(sql);
>> +         s.close();
>> +    }
>> +
>> +    /**
>>      * Set slave db in replication slave mode
>>      */
>>     void startSlave(String clientVM,
>> @@ -1147,10 +1181,7 @@
>>         { // Use full classpath when running locally. Can not vary server versions!
>>             slaveClassPath = classPath;
>>         }
>> -        String URL = DB_PROTOCOL
>> -                +"://"+slaveHost
>> -                +":"+slaveServerPort+"/"
>> -                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
>> +        String URL = slaveURL(dbName)
>>                 +";startSlave=true;slaveHost="+slaveReplInterface
>>                 +";slavePort="+slaveReplPort;
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>> @@ -1191,10 +1222,7 @@
>>             int slaveReplPort)
>>             throws Exception
>>     {
>> -        final String URL = DB_PROTOCOL
>> -                +"://"+slaveHost
>> -                +":"+slaveServerPort+"/"
>> -                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
>> +        final String URL = slaveURL(dbName)
>>                 +";startSlave=true;slaveHost="+slaveReplInterface
>>                 +";slavePort="+slaveReplPort;
>>
>> @@ -1205,7 +1233,8 @@
>>             final int fSlaveServerPort = slaveServerPort;
>>             final String fConnAttrs = "startSlave=true"
>>                                 +";slaveHost="+slaveReplInterface
>> -                                +";slavePort="+slaveReplPort;
>> +                                +";slavePort="+slaveReplPort
>> +                                +useEncryption(false);
>>             Thread connThread = new Thread(
>>                     new Runnable()
>>             {
>> @@ -1260,10 +1289,7 @@
>>
>>         String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+slaveHost
>> -                +":"+slaveServerPort+"/"
>> -                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
>> +        String URL = slaveURL(dbName)
>>                 +";stopSlave=true";
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>> @@ -1320,10 +1346,7 @@
>>
>>         String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+host
>> -                +":"+serverPort+"/"
>> -                +dbPath+FS+dbSubPath+FS+dbName
>> +        String URL = masterURL(dbName)
>>                 +";failover=true";
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>> @@ -1354,10 +1377,7 @@
>>             int serverPort)
>>             throws Exception
>>     {
>> -        String URL = DB_PROTOCOL
>> -                +"://"+host
>> -                +":"+serverPort+"/"
>> -                +dbPath+FS+dbSubPath+FS+dbName
>> +        String URL = masterURL(dbName)
>>                 +";failover=true";
>>
>>             util.DEBUG("failOver_direct getConnection("+URL+")");
>> @@ -1403,11 +1423,8 @@
>>             masterClassPath = classPath;
>>         }
>>
>> -        String URL = DB_PROTOCOL
>> -                +"://"+masterHost
>> -                +":"+masterServerPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
>> -                +";stopSlave=true";
>> +        String URL = masterURL(dbName)
>> +                +";stopMaster=true";
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>>         if ( masterHost.equals("localhost") )
>> @@ -1429,7 +1446,7 @@
>>                 runUserCommandRemotely(command,
>>                 testClientHost,
>>                 testUser,
>> -                "stopSlave_ij ");
>> +                "stopMaster_ij ");
>>         util.DEBUG(results);
>>     }
>>
>> @@ -1476,7 +1493,7 @@
>>         util.DEBUG("xFindServerPID: " + pid);
>>         return pid;
>>     }
>> -    private void xStopServer(String serverHost, int serverPID)
>> +    void xStopServer(String serverHost, int serverPID)
>>     throws InterruptedException
>>     {
>>         if ( serverPID == -1 || serverPID == 0 )
>> @@ -1493,11 +1510,22 @@
>>     {
>>         util.DEBUG("BEGIN verifySlave "+slaveServerHost+":"
>>                 +slaveServerPort+"/"+slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb);
>> +
>> +        if ( (replicationTest != null) // If 'replicationTest==null' no table was created/filled
>> +                && simpleLoad )
>> +        {
>> +            _verifyDatabase(slaveServerHost, slaveServerPort,
>> +                    slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
>> +                    simpleLoadTuples);
>> +            // return;
>> +        }
>> +
>>         ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
>>         ds.setDatabaseName(slaveDatabasePath + FS + slaveDbSubPath + FS +
>>                            replicatedDb);
>>         ds.setServerName(slaveServerHost);
>>         ds.setPortNumber(slaveServerPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>>         Connection conn = ds.getConnection();
>>
>>         simpleVerify(conn);
>> @@ -1515,11 +1543,22 @@
>>     {
>>         util.DEBUG("BEGIN verifyMaster " + masterServerHost + ":"
>>                 +masterServerPort+"/"+masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb);
>> +
>> +        if ( (replicationTest != null)  // If 'replicationTest==null' no table was created/filled
>> +                && simpleLoad )
>> +        {
>> +            _verifyDatabase(masterServerHost, masterServerPort,
>> +                    masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb,
>> +                    simpleLoadTuples);
>> +            // return;
>> +        }
>> +
>>         ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
>>         ds.setDatabaseName(masterDatabasePath + FS + masterDbSubPath + FS +
>>                            replicatedDb);
>>         ds.setServerName(masterServerHost);
>>         ds.setPortNumber(masterServerPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>>         Connection conn = ds.getConnection();
>>
>>         simpleVerify(conn);
>> @@ -1558,10 +1597,7 @@
>>                 serverHost,serverPort,
>>                 dbName);
>>         /*
>> -        String URL = DB_PROTOCOL
>> -                +"://"+serverHost
>> -                +":"+serverPort+"/"
>> -                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName;
>> +        String URL = slaveURL(dbName);
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>>
>> @@ -1608,10 +1644,7 @@
>>                 serverHost,serverPort,
>>                 dbName);
>>         /*
>> -        String URL = DB_PROTOCOL
>> -                +"://"+serverHost
>> -                +":"+serverPort+"/"
>> -                +masterDatabasePath+FS+masterDbSubPath+FS+dbName;
>> +        String URL = masterURL(dbName);
>>         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                 + PS + derbyVersion +FS+ "derbytools.jar";
>>
>> @@ -1664,7 +1697,7 @@
>>      */
>>
>>
>> -    private String runUserCommand(String command,
>> +    /* private */ String runUserCommand(String command,
>>             String testUser)
>>     {
>>         util.DEBUG("Execute '"+ command +"'");
>> @@ -2012,6 +2045,10 @@
>>         unFreezeDB = null;
>>         util.DEBUG("unFreezeDB: " + unFreezeDB);
>>
>> +        simpleLoad = System.getProperty("derby.tests.replSimpleLoad", "true")
>> +                                                     .equalsIgnoreCase("true");
>> +        util.DEBUG("simpleLoad: " + simpleLoad);
>> +
>>         /* Done in subclasses
>>         replicationTest = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun";
>>         util.DEBUG("replicationTest: " + replicationTest);
>> @@ -2771,11 +2808,8 @@
>>         if ( !existingDB )
>>         {
>>             // Create it!
>> -            String URL = DB_PROTOCOL
>> -                    +"://"+serverHost
>> -                    +":"+serverPort+"/"
>> -                    +masterDatabasePath+FS+dbSubPath+FS+database // FIXME! for slave load!
>> -                    +";create=true"; // Creating!
>> +            String URL = masterURL(database)
>> +                    +";create=true"; // Creating! No need for encryption here?
>>             String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
>>                     + PS + derbyVersion +FS+ "derbyTesting.jar"
>>                     + PS + derbyVersion +FS+ "derbytools.jar";
>> @@ -2810,6 +2844,59 @@
>>
>>     }
>>
>> +    void makeReadyForReplication()
>> +        throws Exception
>> +    {   // Replace the following code in all tests with a call to makeReadyForReplication()!
>> +        cleanAllTestHosts();
>> +
>> +        initEnvironment();
>> +
>> +        initMaster(masterServerHost,
>> +                replicatedDb);
>> +
>> +        masterServer = startServer(masterJvmVersion, derbyMasterVersion,
>> +                masterServerHost,
>> +                ALL_INTERFACES,
>> +                masterServerPort,
>> +                masterDbSubPath);
>> +
>> +        slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
>> +                slaveServerHost,
>> +                ALL_INTERFACES,
>> +                slaveServerPort,
>> +                slaveDbSubPath);
>> +
>> +        startServerMonitor(slaveServerHost);
>> +
>> +        bootMasterDatabase(jvmVersion,
>> +                masterDatabasePath +FS+ masterDbSubPath,
>> +                replicatedDb,
>> +                masterServerHost,
>> +                masterServerPort,
>> +                null // bootLoad, // The "test" to start when booting db.
>> +                );
>> +
>> +        initSlave(slaveServerHost,
>> +                jvmVersion,
>> +                replicatedDb);
>> +
>> +        startSlave(jvmVersion, replicatedDb,
>> +                slaveServerHost,
>> +                slaveServerPort,
>> +                slaveServerHost,
>> +                slaveReplPort,
>> +                testClientHost);
>> +
>> +        startMaster(jvmVersion, replicatedDb,
>> +                masterServerHost,
>> +                masterServerPort,
>> +                masterServerHost,
>> +                slaveServerPort,
>> +                slaveServerHost,
>> +                slaveReplPort);
>> +
>> +    }
>> +
>>     ///////////////////////////////////////////////////////////////////////////
>>     /* Remove any servers or tests still running
>>      */
>> @@ -3319,6 +3406,7 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(serverHost);
>>         ds.setPortNumber(serverPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>>         Connection conn = ds.getConnection();
>>
>>         PreparedStatement ps = conn.prepareStatement("create table t(i integer primary key, s varchar(64))");
>> @@ -3349,6 +3437,7 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(serverHost);
>>         ds.setPortNumber(serverPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>>         Connection conn = ds.getConnection();
>>
>>         _verify(conn,_noTuplesInserted);
>> @@ -3372,4 +3461,43 @@
>>         assertEquals("Expected " +(_noTuplesInserted-1) +" max, got " + max +".",
>>                      _noTuplesInserted - 1, max);
>>     }
>> +
>> +    Connection getConnection(String serverHost, int serverPort,
>> +            String databasePath, String dbSubPath, String replicatedDb)
>> +        throws SQLException
>> +    {
>> +        String db = databasePath +FS+dbSubPath +FS+ replicatedDb;
>> +        String connectionURL = "jdbc:derby:"
>> +                + "//" + serverHost + ":" + serverPort + "/"
>> +                + db;
>> +        util.DEBUG(connectionURL);
>> +        return DriverManager.getConnection(connectionURL);
>> +    }
>> +
>> +    String masterURL(String dbName)
>> +    {
>> +        return DB_PROTOCOL
>> +                +"://"+masterServerHost
>> +                +":"+masterServerPort+"/"
>> +                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
>> +                +useEncryption(false);
>> +    }
>> +    String masterLoadURL(String dbSubPath)
>> +    {
>> +        return DB_PROTOCOL
>> +                +"://"+masterServerHost
>> +                +":"+masterServerPort+"/"
>> +                +masterDatabasePath+FS+dbSubPath
>> +                +useEncryption(false);
>> +    }
>> +
>> +    String slaveURL(String dbName)
>> +    {
>> +        return DB_PROTOCOL
>> +                +"://"+slaveServerHost
>> +                +":"+slaveServerPort+"/"
>> +                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
>> +                +useEncryption(false);
>> +    }
>> +
>>  }
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java Thu May 21 13:13:04 2009
>> @@ -46,16 +46,6 @@
>>         super(testcaseName);
>>     }
>>
>> -    protected void setUp() throws Exception
>> -    {
>> -        super.setUp();
>> -    }
>> -
>> -    protected void tearDown() throws Exception
>> -    {
>> -        super.tearDown();
>> -    }
>> -
>>     public static Test suite()
>>     {
>>         TestSuite suite = new TestSuite("ReplicationRun_Local Suite");
>> @@ -77,7 +67,13 @@
>>     ////
>>     //////////////////////////////////////////////////////////////
>>
>> -    public void testReplication_Local_existingTestsAsReplLoad()
>> +    /**
>> +     * Test the "normal" replication scenario:
>> +     * Load on the master db while replicating to slave db,
>> +     * then verify that slave db is correct after failover.
>> +     * @throws java.lang.Exception
>> +     */
>> +    public void testReplication_Local_TestStraightReplication()
>>     throws Exception
>>     {
>>         cleanAllTestHosts();
>>
>> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java?rev=777105&view=auto
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java (added)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java Thu May 21 13:13:04 2009
>> @@ -0,0 +1,156 @@
>> +/*
>> +
>> +Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_1Indexing
>> +
>> +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.sql.Connection;
>> +import java.sql.PreparedStatement;
>> +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.SecurityManagerSetup;
>> +
>> +
>> +/**
>> + * Run a replication test on localhost
>> + * by using default values for master and slave hosts,
>> + * and master and slave ports.
>> + * Verify that indexes are replicated.
>> + */
>> +
>> +public class ReplicationRun_Local_1Indexing extends ReplicationRun
>> +{
>> +
>> +    /**
>> +     * Creates a new instance of ReplicationRun_Local
>> +     * @param testcaseName Identifying the test.
>> +     */
>> +    public ReplicationRun_Local_1Indexing(String testcaseName)
>> +    {
>> +        super(testcaseName);
>> +    }
>> +
>> +    public static Test suite()
>> +    {
>> +        TestSuite suite = new TestSuite("ReplicationRun_Local_1Indexing Suite");
>> +
>> +        suite.addTestSuite( ReplicationRun_Local_1Indexing.class    );
>> +
>> +        return SecurityManagerSetup.noSecurityManager(suite);
>> +
>> +    }
>> +
>> +    /**
>> +     * Verify that indexes created on master before failover
>> +     * are available in slave database after failover.
>> +     * @throws java.lang.Exception
>> +     */
>> +    public void testReplication_Local_1_Indexing()
>> +    throws Exception
>> +    {
>> +        makeReadyForReplication();
>> +
>> +        // Replication "load"
>> +        String masterDbPath = masterDatabasePath + FS + masterDbSubPath + FS +
>> +                replicatedDb;
>> +
>> +        int tuplesToInsert = 10000;
>> +        executeOnMaster("create table t(i integer primary key, s varchar(64), ii integer)");
>> +
>> +        executeOnMaster("create index index1ii on t(ii)");
>> +        executeOnMaster("create index index1s on t(s)");
>> +        int tuplesInserted = 0;
>> +
>> +        _fillTableOnServer(masterServerHost, masterServerPort,
>> +                masterDbPath, tuplesInserted, tuplesToInsert);
>> +        tuplesInserted = tuplesInserted + tuplesToInsert;
>> +
>> +        executeOnMaster("drop index index1ii");
>> +        executeOnMaster("drop index index1s");
>> +
>> +        executeOnMaster("create index index2ii on t(ii)");
>> +        executeOnMaster("create index index2s on t(s)");
>> +
>> +        _fillTableOnServer(masterServerHost, masterServerPort,
>> +                masterDbPath, tuplesToInsert, tuplesToInsert);
>> +        tuplesInserted = tuplesInserted + tuplesToInsert;
>> +
>> +        failOver(jvmVersion,
>> +                masterDatabasePath, masterDbSubPath, replicatedDb,
>> +                masterServerHost, masterServerPort,
>> +                testClientHost);
>> +
>> +        connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
>> +                slaveServerHost,slaveServerPort,
>> +                testClientHost);
>> +
>> +        // verifySlave();
>> +        String slaveDbPath = slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb;
>> +        _verifyDatabase(slaveServerHost, slaveServerPort,
>> +            slaveDbPath, tuplesInserted);
>> +        _verifyIndexOnSlave("index2ii");
>> +        _verifyIndexOnSlave("index2s");
>> +
>> +        // We should verify the master as well,
>> +        // at least to see that we still can connect.
>> +        // verifyMaster();
>> +        masterDbPath = masterDatabasePath +FS+ masterDbSubPath +FS+ replicatedDb;
>> +        _verifyDatabase(masterServerHost, masterServerPort,
>> +            masterDbPath, tuplesInserted);
>> +    }
>> +    void _fillTableOnServer(String serverHost,
>> +            int serverPort,
>> +            String dbPath,
>> +            int startVal,
>> +            int _noTuplesToInsert)
>> +        throws SQLException
>> +    {
>> +        ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
>> +        ds.setDatabaseName(dbPath);
>> +        ds.setServerName(serverHost);
>> +        ds.setPortNumber(serverPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>> +        Connection conn = ds.getConnection();
>> +
>> +        PreparedStatement ps = conn.prepareStatement("insert into t values (?,?,?)");
>> +        for (int i = 0; i< _noTuplesToInsert; i++)
>> +        {
>> +            ps.setInt(1,(i+startVal));
>> +            ps.setString(2,"dilldall"+(i+startVal));
>> +            ps.setInt(3,(i+startVal) % (_noTuplesToInsert/10) );
>> +            ps.execute();
>> +            if ( (i % 10000) == 0 ) conn.commit();
>> +        }
>> +
>> +        _verify(conn, startVal + _noTuplesToInsert);
>> +
>> +        conn.close();
>> +    }
>> +
>> +    private void _verifyIndexOnSlave(String indexName)
>> +        throws SQLException
>> +    {
>> +
>> +        // Verify we may drop the index.
>> +        executeOnSlave("drop index " + indexName);  // Will fail if index does no exist
>> +    }
>> +}
>>
>> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java Thu May 21 13:13:04 2009
>> @@ -26,9 +26,9 @@
>>
>>
>>  /**
>> - * Run a replication test on localhost
>> - * by using default values for master and slave hosts,
>> - * and master and slave ports.
>> + * Defining startSlave, stopmaster, stopSlave and
>> + * failOver methods returning SQLException for
>> + * negative testing (ReplicationRun_Local_3 set of tests).
>>  *
>>  */
>>
>> @@ -44,16 +44,6 @@
>>         super(testcaseName);
>>     }
>>
>> -    protected void setUp() throws Exception
>> -    {
>> -        super.setUp();
>> -    }
>> -
>> -    protected void tearDown() throws Exception
>> -    {
>> -        super.tearDown();
>> -    }
>> -
>>     //////////////////////////////////////////////////////////////
>>     ////
>>     //// The replication test framework (testReplication()):
>> @@ -73,7 +63,8 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(serverHost);
>>         ds.setPortNumber(serverPort);
>> -        ds.setConnectionAttributes("failover=true");
>> +        ds.setConnectionAttributes("failover=true"
>> +                +useEncryption(false));
>>         try {
>>             Connection conn = ds.getConnection(); //
>>             conn.close();
>> @@ -96,7 +87,8 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(serverHost);
>>         ds.setPortNumber(serverPort);
>> -        ds.setConnectionAttributes("startSlave=true;create=true");
>> +        ds.setConnectionAttributes("startSlave=true;create=true"
>> +                +useEncryption(true));
>>         try {
>>             Connection conn = ds.getConnection(); // XRE10 - REPLICATION_CONFLICTING_ATTRIBUTES
>>             conn.close();
>> @@ -113,7 +105,8 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(masterServerHost);
>>         ds.setPortNumber(masterServerPort);
>> -        ds.setConnectionAttributes("stopMaster=true");
>> +        ds.setConnectionAttributes("stopMaster=true"
>> +                +useEncryption(false));
>>         try {
>>             Connection conn = ds.getConnection(); //
>>             conn.close();
>> @@ -133,7 +126,8 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(slaveServerHost);
>>         ds.setPortNumber(slaveServerPort);
>> -        ds.setConnectionAttributes("stopSlave=true");
>> +        ds.setConnectionAttributes("stopSlave=true"
>> +                +useEncryption(false));
>>         try {
>>             Connection conn = ds.getConnection();
>>             conn.close();
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java Thu May 21 13:13:04 2009
>> @@ -29,6 +29,12 @@
>>  * Run a replication test on localhost
>>  * by using default values for master and slave hosts,
>>  * and master and slave ports.
>> + * Test that
>> + * - stopSlave is not accepted on replicating slave,
>> + * - stopSlave is not accepted on replicating master,
>> + * - stopMaster is accepted on replicating master,
>> + * - stopSlave is not accepted on non-replicating slave host,
>> + * - failOver is not accepted on non-replicating master host.
>>  *
>>  */
>>
>> @@ -44,16 +50,6 @@
>>         super(testcaseName);
>>     }
>>
>> -    protected void setUp() throws Exception
>> -    {
>> -        super.setUp();
>> -    }
>> -
>> -    protected void tearDown() throws Exception
>> -    {
>> -        super.tearDown();
>> -    }
>> -
>>     public static Test suite()
>>     {
>>         TestSuite suite = new TestSuite("ReplicationRun_Local_3_p1 Suite");
>> @@ -134,7 +130,8 @@
>>                 slaveServerHost, // for slaveReplInterface
>>                 slaveReplPort);
>>
>> -        runTest(null, // Returns immediatly if replicationTest is null.
>> +        replicationTest = null; // Used as a flag to verifyMaster and verifySlave!
>> +        runTest(replicationTest, // Returns immediatly if replicationTest is null.
>>                 jvmVersion,
>>                 testClientHost,
>>                 masterServerHost, masterServerPort,
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java Thu May 21 13:13:04 2009
>> @@ -31,6 +31,7 @@
>>  * Run a replication test on localhost
>>  * by using default values for master and slave hosts,
>>  * and master and slave ports.
>> + * Verify that a second failover is not accepted.
>>  *
>>  */
>>
>> @@ -50,16 +51,6 @@
>>         super(testcaseName);
>>     }
>>
>> -    protected void setUp() throws Exception
>> -    {
>> -        super.setUp();
>> -    }
>> -
>> -    protected void tearDown() throws Exception
>> -    {
>> -        super.tearDown();
>> -    }
>> -
>>     public static Test suite()
>>     {
>>         TestSuite suite = new TestSuite("ReplicationRun_Local_3_p3 Suite");
>> @@ -81,6 +72,10 @@
>>     ////
>>     //////////////////////////////////////////////////////////////
>>
>> +    /**
>> +     * Verify that a second failover is not accepted.
>> +     * @throws java.lang.Exception
>> +     */
>>     public void testReplication_Local_3_p3_StateNegativeTests()
>>     throws Exception
>>     {
>> @@ -138,7 +133,8 @@
>>                 slaveServerHost, // for slaveReplInterface
>>                 slaveReplPort);
>>
>> -        runTest(null, // Returns immediatly if replicationTest is null.
>> +        replicationTest = null; // Used as a flag to verifyMaster and verifySlave!
>> +        runTest(replicationTest, // Returns immediatly if replicationTest is null.
>>                 jvmVersion,
>>                 testClientHost,
>>                 masterServerHost, masterServerPort,
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java Thu May 21 13:13:04 2009
>> @@ -29,9 +29,8 @@
>>
>>
>>  /**
>> - * Run a replication test on localhost
>> - * by using default values for master and slave hosts,
>> - * and master and slave ports.
>> + * Verify that "internal_stopslave=true" is
>> + * NOT accepted as user supplied connection attr.
>>  *
>>  */
>>
>> @@ -47,16 +46,6 @@
>>         super(testcaseName);
>>     }
>>
>> -    protected void setUp() throws Exception
>> -    {
>> -        super.setUp();
>> -    }
>> -
>> -    protected void tearDown() throws Exception
>> -    {
>> -        super.tearDown();
>> -    }
>> -
>>     public static Test suite()
>>     {
>>         TestSuite suite = new TestSuite("ReplicationRun_Local_3_p4 Suite");
>> @@ -78,6 +67,12 @@
>>     ////
>>     //////////////////////////////////////////////////////////////
>>
>> +    /**
>> +     * Test to verify that "internal_stopslave=true" is
>> +     * NOT accepted as connection attr. on the slave.
>> +     * "internal_stopslave=true" is for internal use only.
>> +     * @throws java.lang.Exception
>> +     */
>>     public void testReplication_Local_3_p4_StateNegativeTests()
>>     throws Exception
>>     {
>> @@ -129,8 +124,8 @@
>>                 slaveServerHost, // for slaveReplInterface
>>                 slaveReplPort);
>>
>> -
>> -        runTest(null, // Returns immediatly if replicationTest is null.
>> +        replicationTest = null; // Used as a flag to verifyMaster and verifySlave!
>> +        runTest(replicationTest, // Returns immediatly if replicationTest is null.
>>                 jvmVersion,
>>                 testClientHost,
>>                 masterServerHost, masterServerPort,
>> @@ -183,6 +178,7 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(slaveServerHost);
>>         ds.setPortNumber(slaveServerPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>>         try {
>>             Connection conn = ds.getConnection(); //
>>             conn.close();
>> @@ -201,7 +197,8 @@
>>         ds.setDatabaseName(dbPath);
>>         ds.setServerName(slaveServerHost);
>>         ds.setPortNumber(slaveServerPort);
>> -        ds.setConnectionAttributes("internal_stopslave=true");
>> +        ds.setConnectionAttributes("internal_stopslave=true"
>> +                +useEncryption(false));
>>         try {
>>             Connection conn = ds.getConnection(); //
>>             conn.close();
>>
>> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java?rev=777105&view=auto
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java (added)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java Thu May 21 13:13:04 2009
>> @@ -0,0 +1,253 @@
>> +/*
>> +
>> +Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p5
>> +
>> +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.DriverManager;
>> +import java.sql.SQLException;
>> +import java.sql.Statement;
>> +import junit.framework.Test;
>> +import junit.framework.TestSuite;
>> +import org.apache.derbyTesting.junit.SecurityManagerSetup;
>> +
>> +
>> +/**
>> + * Run a replication test on localhost
>> + * by using default values for master and slave hosts,
>> + * and master and slave ports.
>> + * Test DERBY-3924 verifying the fix for DERBY-3878.
>> + *
>> + */
>> +
>> +public class ReplicationRun_Local_3_p5 extends ReplicationRun_Local_3
>> +{
>> +
>> +    /**
>> +     * Creates a new instance of ReplicationRun_Local
>> +     * @param testcaseName Identifying the test.
>> +     */
>> +    // String getDerbyServerPID = null;
>> +    public ReplicationRun_Local_3_p5(String testcaseName)
>> +    {
>> +        super(testcaseName);
>> +
>> +    }
>> +
>> +    public static Test suite()
>> +    {
>> +        TestSuite suite = new TestSuite("ReplicationRun_Local_3_p5 Suite");
>> +
>> +        suite.addTestSuite( ReplicationRun_Local_3_p5.class);
>> +
>> +        return SecurityManagerSetup.noSecurityManager(suite);
>> +
>> +    }
>> +
>> +    /**
>> +     * Test that DERBY-3924 fixed DERBY-3878.
>> +     * @throws java.lang.Exception
>> +     */
>> +    public void testReplication_Local_3_p5_DERBY_3878()
>> +    throws Exception
>> +    {
>> +        makeReadyForReplication();
>> +
>> +        // getDerbyServerPID = userDir +FS+ "getDerbyServerPID";
>> +        // mk_getDerbyServerPID_Cmd(getDerbyServerPID);
>> +
>> +        // Run a "load" on the master to make sure there
>> +        // has been replication to slave.
>> +        replicationTest = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun";
>> +        util.DEBUG("replicationTest: " + replicationTest);
>> +        replicationVerify = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun_Verify";
>> +        util.DEBUG("replicationVerify: " + replicationVerify);
>> +
>> +        runTest(replicationTest, // Returns immediatly if replicationTest is null.
>> +                jvmVersion,
>> +                testClientHost,
>> +                masterServerHost, masterServerPort,
>> +                replicatedDb);
>> +
>> +        _killMasterServer(); // "Crash" master.
>> +
>> +        Thread.sleep(5000L); // Need time to settle down if we had load.
>> +        // With this sleep we always have REPLICATION_SLAVE_SHUTDOWN_OK
>> +        String expected = "XRE42"; // REPLICATION_SLAVE_SHUTDOWN_OK
>> +        // if ( replicationTest != null ) expected = "XRE41"; // SLAVE_OPERATION_DENIED_WHILE_CONNECTED  = "XRE41" if had load and no sleep
>> +        assertException(
>> +            _stopSlave(slaveServerHost, slaveServerPort,
>> +                slaveDatabasePath +FS+ slaveDbSubPath +FS+ replicatedDb), // OK when master is gone.
>> +            expected);
>> +
>> +        // Try to re-establish replication mode:
>> +        // No change. Thread.sleep(5000L); // Need time to settle down if we had load?
>> +        masterServer = startServer(masterJvmVersion, derbyMasterVersion,
>> +                masterServerHost,
>> +                ALL_INTERFACES,
>> +                masterServerPort,
>> +                masterDbSubPath);
>> +
>> +        if ( masterServerHost.equalsIgnoreCase("localhost") || localEnv )
>> +        {
>> +             String URL = masterURL(replicatedDb);
>> +            Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
>> +            util.DEBUG("bootMasterDatabase getConnection("+URL+")");
>> +            Connection conn = DriverManager.getConnection(URL);
>> +            Statement s = conn.createStatement();
>> +            s.execute("call syscs_util.syscs_freeze_database()");
>> +            conn.close();
>> +        }
>> +        else
>> +        {
>> +            runTest(freezeDB,
>> +                    jvmVersion,
>> +                    testClientHost,
>> +                    masterServerHost, masterServerPort,
>> +                    replicatedDb);
>> +        }
>> +        initSlave(slaveServerHost, // Copy master contents to slave again.
>> +                jvmVersion,
>> +                replicatedDb);
>> +
>> +        /* Slave server still running, so do not need:
>> +        slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
>> +                slaveServerHost,
>> +                ALL_INTERFACES,
>> +                slaveServerPort,
>> +                slaveDbSubPath); */
>> +
>> +        Thread.sleep(5000L); // Need time to settle down if we had load.
>> +        startSlave(jvmVersion, replicatedDb, // should cause an address-already-in-use exception without the fix for DERBY-3878
>> +                slaveServerHost,             // Verified that we get 'Address already in use' and then hangs!
>> +                slaveServerPort,             // without the fix for DERBY-3878
>> +                slaveServerHost,
>> +                slaveReplPort,
>> +                testClientHost);
>> +
>> +        startMaster(jvmVersion, replicatedDb,
>> +                masterServerHost,
>> +                masterServerPort,
>> +                masterServerHost,
>> +                slaveServerPort,
>> +                slaveServerHost,
>> +                slaveReplPort);
>> +        // Should now be back in "normal" replication mode state.
>> +
>> +        assertSqlStateSlaveConn("XRE08"); // REPLICATION_SLAVE_STARTED_OK
>> +
>> +        failOver(jvmVersion,
>> +                masterDatabasePath, masterDbSubPath, replicatedDb,
>> +                masterServerHost,  // Where the master db is run.
>> +                masterServerPort,
>> +                testClientHost);
>> +
>> +        connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
>> +                slaveServerHost,slaveServerPort,
>> +                testClientHost);
>> +
>> +        verifySlave(); // Starts slave and does a very simple verification.
>> +
>> +        // We should verify the master as well, at least to see that we still can connect.
>> +        verifyMaster();
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                slaveServerHost, slaveServerPort);
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                masterServerHost, masterServerPort);
>> +
>> +    }
>> +
>> +    private void _killMasterServer()
>> +        throws ClassNotFoundException, SQLException
>> +    {
>> +             String URL = masterURL(replicatedDb); // So far only used for master!
>> +            Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
>> +            Connection conn = DriverManager.getConnection(URL);
>> +            Statement s = conn.createStatement();
>> +            conn.setAutoCommit(false); //
>> +            s.execute("create procedure kill(in p integer)"
>> +                    + " parameter style java"
>> +                    + " no sql"
>> +                    + " language java"
>> +                    + " external name"
>> +                      + "'java.lang.System.exit'");
>> +            try{
>> +                s.execute("call kill(0)");
>> +            } catch (SQLException se)
>> +            {
>> +                int errCode = se.getErrorCode();
>> +                String msg = se.getMessage();
>> +                String sState = se.getSQLState();
>> +                String expectedState = "08006";
>> +                msg = errCode + " " + sState + " " + msg
>> +                        + ". Expected: "+ expectedState;
>> +                if ( (errCode == 40000)
>> +                && (sState.equalsIgnoreCase(expectedState) ) )
>> +                {
>> +                    util.DEBUG("As expected. " + msg);
>> +                }
>> +                else
>> +                {
>> +                    assertTrue("kill() failed. " + msg, false);
>> +                }
>> +
>> +            }
>> +            /* The connection is now gone!
>> +            conn.rollback();
>> +            conn.close();
>> +            */
>> +
>> +    }
>> +
>> +    /*
>> +    private void _killServer(String masterServerHost, int masterServerPort)
>> +    throws InterruptedException, IOException
>> +    {
>> +        // This will work for "Unix" only!!
>> +        util.DEBUG("_killServer: " + masterServerHost +":" + masterServerPort);
>> +
>> +        String PID = runUserCommand(getDerbyServerPID + " " + masterServerPort,testUser);
>> +        runUserCommand("kill " + PID,testUser);
>> +
>> +    }
>> +
>> +    private void mk_getDerbyServerPID_Cmd(String cmdName)
>> +            throws IOException
>> +    {
>> +        String cmd = "#!/bin/bash"
>> +            + LF + "PORTNO=$1"
>> +            + LF + "if [ \"${PORTNO}\" == \"\" ]"
>> +            + LF + "then"
>> +            + LF + "  echo UNDEFINED_PORT_NUMBER"
>> +            + LF + "  PORTNO=UNDEFINED_PORT_NUMBER"
>> +            + LF + "fi"
>> +            + LF + "ps auxwww"
>> +              + "| grep \"org.apache.derby.drda.NetworkServerControl "
>> +              + "start -h 0.0.0.0 -p ${PORTNO}\" | grep -v grep "
>> +              + "| gawk '{ print $2 }'";
>> +        util.writeToFile(cmd, cmdName);
>> +        runUserCommand("chmod +x " + cmdName,testUser);
>> +    }
>> +    */
>> +
>> +}
>>
>> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java?rev=777105&view=auto
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java (added)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java Thu May 21 13:13:04 2009
>> @@ -0,0 +1,250 @@
>> +/*
>> +
>> +Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p6
>> +
>> +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.sql.Connection;
>> +import java.sql.DriverManager;
>> +import java.sql.PreparedStatement;
>> +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.SecurityManagerSetup;
>> +
>> +
>> +/**
>> + * Run a replication test on localhost
>> + * by using default values for master and slave hosts,
>> + * and master and slave ports.
>> + * Test for DERBY-3896.
>> + *
>> + */
>> +
>> +public class ReplicationRun_Local_3_p6 extends ReplicationRun_Local_3
>> +{
>> +
>> +    /**
>> +     * Creates a new instance of ReplicationRun_Local
>> +     * @param testcaseName Identifying the test.
>> +     */
>> +    String getDerbyServerPID = null;
>> +    public ReplicationRun_Local_3_p6(String testcaseName)
>> +    {
>> +        super(testcaseName);
>> +
>> +    }
>> +
>> +    public static Test suite()
>> +    {
>> +        TestSuite suite = new TestSuite("ReplicationRun_Local_3_p6 Suite");
>> +
>> +        suite.addTestSuite( ReplicationRun_Local_3_p6.class);
>> +
>> +        return SecurityManagerSetup.noSecurityManager(suite);
>> +
>> +    }
>> +
>> +    /* ENABLE WHEN DERBY-3896 IS FIXED!
>> +    public void testReplication_Local_3_p6_DERBY_3896()
>> +    throws Exception
>> +    {
>> +        derby_3896(false); // Autocommit off during create table before starting replication
>> +    }
>> +    */
>> +
>> +    /**
>> +     * Test the DERBY-3896 scenario but with autocommit on which
>> +     * does not fail.
>> +     * DERBY-3896: Autocommit off during create table before starting replication
>> +     * causes uncommitted data not being replicated.
>> +     * @throws java.lang.Exception
>> +     */
>> +    public void testReplication_Local_3_p6_autocommit_OK()
>> +    throws Exception
>> +    {
>> +        derby_3896(true);
>> +    }
>> +
>> +    private void derby_3896(boolean autocommit)
>> +    throws Exception
>> +    {
>> +        // makeReadyForReplication(); expanded for more control:
>> +        // BEGIN
>> +        cleanAllTestHosts();
>> +
>> +        initEnvironment();
>> +
>> +        initMaster(masterServerHost,
>> +                replicatedDb);
>> +
>> +        masterServer = startServer(masterJvmVersion, derbyMasterVersion,
>> +                masterServerHost,
>> +                ALL_INTERFACES,
>> +                masterServerPort,
>> +                masterDbSubPath);
>> +
>> +        slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
>> +                slaveServerHost,
>> +                ALL_INTERFACES,
>> +                slaveServerPort,
>> +                slaveDbSubPath);
>> +
>> +        startServerMonitor(slaveServerHost);
>> +
>> +        // Must expand bootMasterDatabase() since it also freezes db!
>> +        // BEGIN P1
>> +        String URL = masterURL(replicatedDb)
>> +                +";create=true"
>> +                +useEncryption(true);
>> +
>> +        if ( masterServerHost.equalsIgnoreCase("localhost") || localEnv )
>> +        {
>> +            util.DEBUG("bootMasterDatabase getConnection("+URL+")");
>> +            Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
>> +            Connection conn = DriverManager.getConnection(URL);
>> +            conn.close();
>> +        }
>> +        else
>> +        {
>> +            assertTrue("NOT IMPLEMENTED for non-local host!", false);
>> +        }
>> +        // END P1
>> +
>> +        // Create and fill a table to have a NON-empty master db.
>> +
>> +        // BEGIN DERBY-3896
>> +        Connection mConn = _getConnection(masterDatabasePath, masterDbSubPath,
>> +                replicatedDb, masterServerHost, masterServerPort);
>> +
>> +        if ( ! autocommit ) mConn.setAutoCommit(false); // Autocommit off.
>> +        // Autocommit off causes uncommitted data not being replicated - DERBY-3896.
>> +
>> +        PreparedStatement ps = mConn.prepareStatement("create table t(i integer)");
>> +        ps.execute();
>> +        ps = mConn.prepareStatement("insert into t values 0,1,2,3");
>> +        int _noTuplesInserted = 4;
>> +        ps.execute();
>> +
>> +        _verifyTable(mConn, _noTuplesInserted);
>> +        // END DERBY-3896
>> +
>> +        // BEGIN P2
>> +        util.DEBUG("************************** DERBY-???? Preliminary needs to freeze db before copying to slave and setting replication mode.");
>> +        if ( masterServerHost.equalsIgnoreCase("localhost") || localEnv )
>> +        {
>> +           URL = masterURL(replicatedDb);
>> +            Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
>> +            util.DEBUG("bootMasterDatabase getConnection("+URL+")");
>> +            Connection conn = DriverManager.getConnection(URL);
>> +            Statement s = conn.createStatement();
>> +            s.execute("call syscs_util.syscs_freeze_database()");
>> +            conn.close();
>> +        }
>> +        else
>> +        {
>> +            assertTrue("NOT IMPLEMENTED for non-local host!", false);
>> +        }
>> +        util.DEBUG("bootMasterDatabase done.");
>> +        // END P2
>> +
>> +        // Copy master to slave:
>> +        initSlave(slaveServerHost,
>> +                jvmVersion,
>> +                replicatedDb);
>> +
>> +        startSlave(jvmVersion, replicatedDb,
>> +                slaveServerHost,
>> +                slaveServerPort,
>> +                slaveServerHost,
>> +                slaveReplPort,
>> +                testClientHost);
>> +
>> +        startMaster(jvmVersion, replicatedDb,
>> +                masterServerHost,
>> +                masterServerPort,
>> +                masterServerHost,
>> +                slaveServerPort,
>> +                slaveServerHost,
>> +                slaveReplPort);
>> +        // END
>> +
>> +        mConn.commit();
>> +
>> +        failOver(jvmVersion,
>> +                masterDatabasePath, masterDbSubPath, replicatedDb,
>> +                masterServerHost,  // Where the master db is run.
>> +                masterServerPort,
>> +                testClientHost);
>> +
>> +        connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
>> +                slaveServerHost,slaveServerPort,
>> +                testClientHost);
>> +
>> +        // verifySlave(); // Can't be used here because we don't have standard load (tables).
>> +
>> +        Connection sConn = _getConnection(slaveDatabasePath, slaveDbSubPath,
>> +                replicatedDb,slaveServerHost,slaveServerPort);
>> +        _verifyTable(sConn, _noTuplesInserted); // Verify the test specific table!
>> +
>> +        // We should verify the master as well, at least to see that we still can connect.
>> +        // verifyMaster(); // Can't be used here because we don't have standard load (tables).
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                slaveServerHost, slaveServerPort);
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                masterServerHost, masterServerPort);
>> +
>> +    }
>> +
>> +    private Connection _getConnection(String databasePath, String dbSubPath,
>> +            String dbName, String serverHost, int serverPort)
>> +        throws SQLException
>> +    {
>> +        ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
>> +        ds.setDatabaseName(databasePath +FS+ dbSubPath +FS+ dbName);
>> +        ds.setServerName(serverHost);
>> +        ds.setPortNumber(serverPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>> +        return ds.getConnection();
>> +    }
>> +
>> +    private void _verifyTable(Connection conn, int noTuplesInserted)
>> +        throws SQLException
>> +    {
>> +        Statement s = conn.createStatement();
>> +        ResultSet rs = s.executeQuery("select count(*) from t");
>> +        rs.next();
>> +        int count = rs.getInt(1);
>> +        rs = s.executeQuery("select max(i) from t");
>> +        rs.next();
>> +        int max = rs.getInt(1);
>> +        util.DEBUG("_verify: " + count + "/" + noTuplesInserted + " " + max +
>> +                   "/" + (noTuplesInserted - 1));
>> +        assertEquals("Expected "+ noTuplesInserted +" tuples, got "+ count +".",
>> +                     noTuplesInserted, count);
>> +        assertEquals("Expected " +(noTuplesInserted-1) +" max, got " + max +".",
>> +                     noTuplesInserted - 1, max);
>> +    }
>> +
>> +}
>>
>> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java?rev=777105&view=auto
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java (added)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java Thu May 21 13:13:04 2009
>> @@ -0,0 +1,237 @@
>> +/*
>> +
>> +Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_Encrypted_1
>> +
>> +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.sql.Connection;
>> +import java.sql.SQLException;
>> +import junit.framework.Test;
>> +import junit.framework.TestSuite;
>> +import org.apache.derby.jdbc.ClientDataSource;
>> +import org.apache.derbyTesting.junit.SecurityManagerSetup;
>> +
>> +
>> +/**
>> + * Testing replication of encrypted databases.
>> + * Required DERBY-3890.
>> + *
>> + */
>> +
>> +public class ReplicationRun_Local_Encrypted_1 extends ReplicationRun
>> +{
>> +
>> +    public ReplicationRun_Local_Encrypted_1(String testcaseName)
>> +    {
>> +
>> +        super(testcaseName);
>> +
>> +    }
>> +
>> +    protected void setUp() throws Exception
>> +    {
>> +        super.setUp();
>> +        dataEncryption = "bootPassword=dilldall"; // Run the tests with encryption.
>> +    }
>> +
>> +    protected void tearDown() throws Exception
>> +    {
>> +        dataEncryption = null;
>> +        super.tearDown();
>> +    }
>> +
>> +    public static Test suite()
>> +    {
>> +        TestSuite suite = new TestSuite("ReplicationRun_Local_Encrypted_1 Suite");
>> +
>> +        suite.addTestSuite( ReplicationRun_Local_Encrypted_1.class);
>> +
>> +        return SecurityManagerSetup.noSecurityManager(suite);
>> +
>> +    }
>> +
>> +    /**
>> +     * Do a simple test to verify replication can be performed
>> +     * on an encrypted database.
>> +     * @throws java.lang.Exception
>> +     */
>> +    public void testReplication_Encrypted_1_stdLoad()
>> +    throws Exception
>> +    {
>> +        makeReadyForReplication();
>> +
>> +        // Run a "load" on the master to make sure there
>> +        // has been replication to slave.
>> +        replicationTest = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun";
>> +        util.DEBUG("replicationTest: " + replicationTest);
>> +        replicationVerify = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun_Verify";
>> +        util.DEBUG("replicationVerify: " + replicationVerify);
>> +
>> +        runTest(replicationTest, // Returns immediatly if replicationTest is null.
>> +                jvmVersion,
>> +                testClientHost,
>> +                masterServerHost, masterServerPort,
>> +                replicatedDb);
>> +
>> +        failOver(jvmVersion,
>> +                masterDatabasePath, masterDbSubPath, replicatedDb,
>> +                masterServerHost,  // Where the master db is run.
>> +                masterServerPort,
>> +                testClientHost);
>> +
>> +        connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
>> +                slaveServerHost,slaveServerPort,
>> +                testClientHost);
>> +
>> +        verifySlave(); // Starts slave and does a very simple verification.
>> +
>> +        // We should verify the master as well, at least to see that we still can connect.
>> +        verifyMaster();
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                slaveServerHost, slaveServerPort);
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                masterServerHost, masterServerPort);
>> +
>> +    }
>> +
>> +    /**
>> +     * Verify connection to the encrypted, replicated database:
>> +     * A) Database has not been shut down:
>> +     * further connects from the same JVM will succeed
>> +     * - connect without specifying encryption,
>> +     * - blank password,
>> +     * - incorrect password.
>> +     * B) After shutdown:
>> +     * Re-connects without correct password will fail
>> +     * - re-connecting as if un-encrypted,
>> +     * - blank password,
>> +     * - incorrect password.
>> +     * @throws java.lang.Exception
>> +     */
>> +    public void testReplication_Encrypted_1_miniLoad_negative()
>> +    throws Exception
>> +    {
>> +        makeReadyForReplication();
>> +
>> +        // Replication "load"
>> +        String dbPath = masterDatabasePath + FS + masterDbSubPath + FS +
>> +                replicatedDb;
>> +
>> +        int tuplesToInsert = 10000;
>> +        _testInsertUpdateDeleteOnMaster(masterServerHost, masterServerPort,
>> +                dbPath, tuplesToInsert);
>> +
>> +
>> +        failOver(jvmVersion,
>> +                masterDatabasePath, masterDbSubPath, replicatedDb,
>> +                masterServerHost,  // Where the master db is run.
>> +                masterServerPort,
>> +                testClientHost);
>> +
>> +        connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
>> +                slaveServerHost,slaveServerPort,
>> +                testClientHost);
>> +
>> +        // verifySlave();
>> +        String slaveDbPath = slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb;
>> +        _verifyDatabase(slaveServerHost, slaveServerPort,
>> +            slaveDbPath, tuplesToInsert);
>> +
>> +        // We should verify the master as well,
>> +        // at least to see that we still can connect.
>> +        // verifyMaster();
>> +        String masterDbPath = masterDatabasePath +FS+masterDbSubPath +FS+ replicatedDb;
>> +        _verifyDatabase(masterServerHost, masterServerPort,
>> +            masterDbPath, tuplesToInsert);
>> +
>> +        // Since the db has not been shutdown after the correct connect
>> +        // further connects from the same JVM will succeed
>> +        dataEncryption = null;
>> +        assertException(_connectToSlave(slaveServerHost, slaveServerPort,
>> +            slaveDbPath),
>> +            null);
>> +
>> +        // try connecting with blank password
>> +        dataEncryption = "bootPassword=;";
>> +        assertException(_connectToSlave(slaveServerHost, slaveServerPort,
>> +            slaveDbPath),
>> +            null);
>> +
>> +        // try connecting with wrong password
>> +        dataEncryption = "bootPassword=dill2dall";
>> +        assertException(_connectToSlave(slaveServerHost, slaveServerPort,
>> +            slaveDbPath),
>> +            null);
>> +
>> +        // Shutdown the db to test reconnect with incorrect passwords
>> +        shutdownDb(jvmVersion,
>> +            slaveServerHost, slaveServerPort,
>> +            slaveDatabasePath+FS+slaveDbSubPath, replicatedDb,
>> +            testClientHost);
>> +
>> +        // Negative test - try connecting without password
>> +        dataEncryption = null;
>> +        assertException(_connectToSlave(slaveServerHost, slaveServerPort,
>> +            slaveDbPath),
>> +            "XJ040");
>> +
>> +        // Negative test - try connecting with blank password
>> +        dataEncryption = "bootPassword=;";
>> +        assertException(_connectToSlave(slaveServerHost, slaveServerPort,
>> +            slaveDbPath),
>> +            "XJ040");
>> +
>> +        // Negative test - try connecting with wrong password
>> +        dataEncryption = "bootPassword=dill2dall";
>> +        assertException(_connectToSlave(slaveServerHost, slaveServerPort,
>> +            slaveDbPath),
>> +            "XJ040");
>> +
>> +        // Reset to correct passwd.
>> +        dataEncryption = "bootPassword=dilldall";
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                slaveServerHost, slaveServerPort);
>> +
>> +        stopServer(jvmVersion, derbyVersion,
>> +                masterServerHost, masterServerPort);
>> +
>> +    }
>> +
>> +    SQLException _connectToSlave(String slaveServerHost, int slaveServerPort,
>> +            String dbPath)
>> +        throws SQLException
>> +    {
>> +        util.DEBUG("_connectToSlave");
>> +        ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
>> +        ds.setDatabaseName(dbPath);
>> +        ds.setServerName(slaveServerHost);
>> +        ds.setPortNumber(slaveServerPort);
>> +        ds.setConnectionAttributes(useEncryption(false));
>> +        try {
>> +            Connection conn = ds.getConnection();
>> +            conn.close();
>> +            return null; // If successfull.
>> +        } catch (SQLException se) {
>> +            return se;
>> +        }
>> +    }
>> +}
>>
>> Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java Thu May 21 13:13:04 2009
>> @@ -49,16 +49,6 @@
>>         super(testcaseName);
>>     }
>>
>> -    protected void setUp() throws Exception
>> -    {
>> -        super.setUp();
>> -    }
>> -
>> -    protected void tearDown() throws Exception
>> -    {
>> -        super.tearDown();
>> -    }
>> -
>>     public static Test suite()
>>     {
>>         TestSuite suite = new TestSuite("ReplicationRun_Local_StateTest_part2 Suite");
>> @@ -68,6 +58,18 @@
>>         return SecurityManagerSetup.noSecurityManager(suite);
>>     }
>>
>> +    /**
>> +     * Verify that correct response to replication "commands":
>> +     * startSlave, startMaster, stopSlave, stopMaster and failOver,
>> +     * are given when the replicating database is in the following states:
>> +     * Failover has been performed and
>> +     * - slave db has not been shut down,
>> +     * - slave db has been shut down,
>> +     * - slave server has been stopped,
>> +     * - master db has been shut down,
>> +     * - master server has been stopped.
>> +     * @throws java.lang.Exception
>> +     */
>>     public void testReplication_Local_StateTest_part2()
>>     throws Exception
>>     {
>> @@ -203,47 +205,47 @@
>>
>>         // Tests against slave:
>>         assertException(
>> -                startSlave(slaveServerHost,slaveServerPort,
>> +                _startSlave(slaveServerHost,slaveServerPort,
>>                     slaveDatabasePath, replicatedDb,
>>                     slaveReplPort),
>>                 "XRE09");
>>
>>         assertException(
>> -                stopSlave(slaveServerHost,slaveServerPort,
>> +                _stopSlave(slaveServerHost,slaveServerPort,
>>                     slaveDatabasePath, replicatedDb,
>>                     slaveReplPort),
>>                 "XRE40");
>>
>>         assertException(
>> -                failOver(slaveServerHost,slaveServerPort,
>> +                _failOver(slaveServerHost,slaveServerPort,
>>                     slaveDatabasePath, slaveDbSubPath, replicatedDb),
>>                 "XRE07");
>>
>>         // Tests against master:
>>         assertException(
>> -                startMaster(masterServerHost,masterServerPort,
>> +                _startMaster(masterServerHost,masterServerPort,
>>                     masterDatabasePath, replicatedDb,
>>                     slaveServerHost,slaveReplPort),
>>                 "XRE04");
>>
>>         assertException(
>> -                failOver(masterServerHost,masterServerPort,
>> +                _failOver(masterServerHost,masterServerPort,
>>                     masterDatabasePath, masterDbSubPath, replicatedDb),
>>                 "XRE07");
>>
>>         // connect / show tables
>>         assertException(
>> -                executeQuery(mConn, "select count(*) from SYS.SYSTABLES"),
>> +                _executeQuery(mConn, "select count(*) from SYS.SYSTABLES"),
>>                 "08006"); // Thats's just how it is...
>>          assertException(
>> -                executeQuery(mConn, "select count(*) from SYS.SYSTABLES"),
>> +                _executeQuery(mConn, "select count(*) from SYS.SYSTABLES"),
>>                 "08003"); // Thats's just how it is...
>>
>>         // Tests against slave:
>>         Connection sConn = getConnection(slaveServerHost, slaveServerPort,
>>                     slaveDatabasePath, slaveDbSubPath, replicatedDb); // OK
>>          assertException(
>> -                executeQuery(sConn, "select count(*) from SYS.SYSTABLES"),
>> +                _executeQuery(sConn, "select count(*) from SYS.SYSTABLES"),
>>                 null); // null: Should be OK
>>          sConn.close();
>>     }
>> @@ -283,7 +285,7 @@
>>                 + " No value-adding suggestions here.");
>>     }
>>
>> -    SQLException startSlave(String slaveServerHost, int slaveServerPort,
>> +    SQLException _startSlave(String slaveServerHost, int slaveServerPort,
>>             String slaveDatabasePath, String replicatedDb,
>>             int slaveReplPort)
>>     {
>> @@ -307,7 +309,7 @@
>>         }
>>     }
>>
>> -    SQLException stopSlave(String slaveServerHost, int slaveServerPort,
>> +    SQLException _stopSlave(String slaveServerHost, int slaveServerPort,
>>             String slaveDatabasePath, String replicatedDb,
>>             int slaveReplPort)
>>     {
>> @@ -331,7 +333,7 @@
>>         }
>>     }
>>
>> -    SQLException failOver(String serverHost, int serverPort,
>> +    SQLException _failOver(String serverHost, int serverPort,
>>             String databasePath, String dbSubPath, String replicatedDb)
>>     {
>>         String db = databasePath +FS+dbSubPath +FS+ replicatedDb;
>> @@ -352,7 +354,7 @@
>>         }
>>     }
>>
>> -    SQLException startMaster(String masterServerHost, int masterServerPort,
>> +    SQLException _startMaster(String masterServerHost, int masterServerPort,
>>             String databasePath, String replicatedDb,
>>             String slaveServerHost,
>>             int slaveReplPort)
>> @@ -377,18 +379,6 @@
>>         }
>>     }
>>
>> -    Connection getConnection(String serverHost, int serverPort,
>> -            String databasePath, String dbSubPath, String replicatedDb)
>> -        throws SQLException
>> -    {
>> -        String db = databasePath +FS+dbSubPath +FS+ replicatedDb;
>> -        String connectionURL = "jdbc:derby:"
>> -                + "//" + serverHost + ":" + serverPort + "/"
>> -                + db;
>> -        util.DEBUG(connectionURL);
>> -        return DriverManager.getConnection(connectionURL);
>> -    }
>> -
>>     SQLException connectTo(String serverHost, int serverPort,
>>             String databasePath, String dbSubPath, String replicatedDb)
>>     {
>> @@ -409,7 +399,7 @@
>>         }
>>     }
>>
>> -    SQLException executeQuery(Connection conn, String query)
>> +    SQLException _executeQuery(Connection conn, String query)
>>     {
>>         util.DEBUG("executeQuery: " + query);
>>         try
>>
>> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
>> URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java?rev=777105&r1=777104&r2=777105&view=diff
>> ==============================================================================
>> --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java (original)
>> +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java Thu May 21 13:13:04 2009
>> @@ -50,6 +50,8 @@
>>
>>                suite.addTest(ReplicationRun_Local_1.suite());
>>
>> +               suite.addTest(ReplicationRun_Local_1Indexing.suite());
>> +
>>                suite.addTest(ReplicationRun_Local_StateTest_part1.suite());
>>                suite.addTest(ReplicationRun_Local_StateTest_part1_1.suite());
>>                suite.addTest(ReplicationRun_Local_StateTest_part1_2.suite());
>> @@ -65,6 +67,12 @@
>>         suite.addTest(ReplicationRun_Local_3_p3.suite());
>>         suite.addTest(ReplicationRun_Local_3_p4.suite());
>>
>> +               suite.addTest(ReplicationRun_Local_3_p5.suite()); // Test for DERBY-3878
>> +
>> +               suite.addTest(ReplicationRun_Local_Encrypted_1.suite());
>> +
>> +               suite.addTest(ReplicationRun_Local_3_p6.suite());
>> +
>>                return suite;
>>        }
>>  }
>>
>>
>>
>

Mime
View raw message