db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1413740 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/engine/ReadMeFilesTest.java junit/Decorator.java junit/DropDatabaseSetup.java
Date Mon, 26 Nov 2012 17:38:11 GMT
Author: mamta
Date: Mon Nov 26 17:38:10 2012
New Revision: 1413740

URL: http://svn.apache.org/viewvc?rev=1413740&view=rev
Log:
DERBY-5995 (Add a test case to check the 3 readme files get created even when log directory
has been changed with jdbc url attribute logDevice )

Adding a junit test for readme files but the log directory has been redirected using logDevice
jdbc url attribute.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ReadMeFilesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Decorator.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ReadMeFilesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ReadMeFilesTest.java?rev=1413740&r1=1413739&r2=1413740&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ReadMeFilesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ReadMeFilesTest.java
Mon Nov 26 17:38:10 2012
@@ -27,9 +27,12 @@ import java.io.IOException;
 import java.sql.SQLException;
 
 import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.Decorator;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 
@@ -48,14 +51,37 @@ public class ReadMeFilesTest extends Bas
     the database directory 
     */
     private static final String DB_README_FILE_NAME = "README_DO_NOT_TOUCH_FILES.txt";
+    static String logDir = BaseTestCase.getSystemProperty("derby.system.home")+File.separator+"abcs";
 
     public ReadMeFilesTest(String name) {
         super(name);
     }
 
     public static Test suite() {
-        Test suite = TestConfiguration.embeddedSuite(ReadMeFilesTest.class);
-        return TestConfiguration.singleUseDatabaseDecorator(suite);
+    	TestSuite suite = new TestSuite("ReadMeFilesTest");
+
+        //DERBY-5232 (Put a stern README file in log and seg0 directories 
+        // to warn users of corrpution they will cause if they touch files 
+        // there)
+        //Test the existence of readme files for a default embedded config
+        // which means that "log" directory is under the database directory
+        // along with "seg0" directory
+        suite.addTest(TestConfiguration.singleUseDatabaseDecorator(
+            TestConfiguration.embeddedSuite(ReadMeFilesTest.class)));
+
+        //DERBY-5995 (Add a test case to check the 3 readme files get created 
+        // even when log directory has been changed with jdbc url attribute 
+        // logDevice )
+        //Test the existence of readme files for a database configuration
+        // where "log" directory may not be under the database directory.
+        // It's location is determined by jdbc url attribute logDevice.
+        logDir = BaseTestCase.getSystemProperty("derby.system.home")+
+            File.separator+"abcs";
+        suite.addTest(
+            Decorator.logDeviceAttributeDatabase(
+                TestConfiguration.embeddedSuite(ReadMeFilesTest.class),
+                logDir));
+        return suite;
     }
 
     public void testReadMeFilesExist() throws IOException, SQLException {
@@ -64,13 +90,19 @@ public class ReadMeFilesTest extends Bas
         String dbPath = currentConfig.getDatabasePath(currentConfig.getDefaultDatabaseName());
         lookForReadmeFile(dbPath);
         lookForReadmeFile(dbPath+File.separator+"seg0");
-        lookForReadmeFile(dbPath+File.separator+"log");
+
+        String logDevice = currentConfig.getConnectionAttributes().getProperty("logDevice");
+        if (logDevice != null) {
+            lookForReadmeFile(logDir+File.separator+"log");
+        } else {
+            lookForReadmeFile(dbPath+File.separator+"log");
+        }
     }
 
     private void lookForReadmeFile(String path) throws IOException {
         File readmeFile = new File(path,
             DB_README_FILE_NAME);
-        assertTrue(readmeFile + "doesn't exist", PrivilegedFileOpsForTests.exists(readmeFile));
+        assertTrue(readmeFile + "doesn't exist", 
+            PrivilegedFileOpsForTests.exists(readmeFile));
     }
 }
- 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Decorator.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Decorator.java?rev=1413740&r1=1413739&r2=1413740&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Decorator.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/Decorator.java Mon Nov
26 17:38:10 2012
@@ -170,7 +170,22 @@ public class Decorator {
         
         return attributesDatabase(attributes, test);
     }
-    
+
+    /**
+     * Decorate a set of tests to use a single use database with
+     *  logDevice pointing a log directory to non-default location  
+     */
+    public static Test logDeviceAttributeDatabase(Test test, final String logDevice)
+    {
+        Properties attributes = new Properties();
+        if (logDevice != null) {
+            attributes.setProperty("logDevice",logDevice);
+        }
+
+        test = TestConfiguration.singleUseDatabaseDecorator(test);
+        return attributesDatabase(attributes, test);
+    }
+
     /**
      * Decorate a set of tests to use an single
      * use database with TERRITORY_BASED:SECONDARY collation

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java?rev=1413740&r1=1413739&r2=1413740&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/DropDatabaseSetup.java
Mon Nov 26 17:38:10 2012
@@ -90,6 +90,13 @@ class DropDatabaseSetup extends BaseTest
             dbName = dsh + File.separator + dbName;
         }
         removeDirectory(dbName);
+        //DERBY-5995 (Add a test case to check the 3 readme files get created 
+        // even when log directory has been changed with jdbc url attribute 
+        // logDevice )
+        String logDevice = config.getConnectionAttributes().getProperty("logDevice");
+        if (logDevice != null) {
+            removeDirectory(logDevice);
+        }
     }
 
 



Mime
View raw message