You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2013/11/27 09:16:03 UTC
svn commit: r1545957 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ErrorStreamTest.java
Author: myrnavl
Date: Wed Nov 27 08:16:03 2013
New Revision: 1545957
URL: http://svn.apache.org/r1545957
Log:
DERBY-6380; Rolling log files do not get copied in failed directory when a junit test fails
removing two 'fail' commands left over from debugging, and streamlining clean up in ErrorStreamTest
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ErrorStreamTest.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ErrorStreamTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ErrorStreamTest.java?rev=1545957&r1=1545956&r2=1545957&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ErrorStreamTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ErrorStreamTest.java Wed Nov 27 08:16:03 2013
@@ -39,7 +39,6 @@ import org.apache.derbyTesting.functionT
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.BaseTestCase;
import org.apache.derbyTesting.junit.TestConfiguration;
-import org.apache.derbyTesting.junit.Utilities;
/**
@@ -387,7 +386,7 @@ public class ErrorStreamTest extends Bas
getTestConfiguration().shutdownEngine();
assertNotExisting(derby0lck);
-
+
boolean deleted = deleteFile(derby0log);
assertTrue("File " + derby0log + " could not be deleted", deleted);
}
@@ -471,7 +470,7 @@ public class ErrorStreamTest extends Bas
bootDerby();
- // This will generate enough output to roll through all 10 log files
+ // This will generate enough output to roll through all 3 log files
for (int i = 0; i < 10; i++) {
checkAllConsistency(getConnection());
}
@@ -498,7 +497,7 @@ public class ErrorStreamTest extends Bas
if (i == 2) {
assertFileSize(derbyLog, 10000);
}
-
+
boolean deleted = deleteFile(derbyLog);
assertTrue("File " + derbyLog + " could not be deleted", deleted);
}
@@ -814,13 +813,17 @@ public class ErrorStreamTest extends Bas
catch (Throwable running) {
PrintWriter stackOut = null;
try{
- String failPath = PrivilegedFileOpsForTests.getAbsolutePath(getFailureFolder());
- // Copy the logfiles dir
- File origLogFilesDir = new File(DEFAULT_DB_DIR, LOGFILESDIR);
- File newLogFilesDir = new File (failPath, LOGFILESDIR);
- PrivilegedFileOpsForTests.copy(origLogFilesDir,newLogFilesDir);
+ copyFileToFail(LOGFILESDIR);
nullFields();
- removeDirectory(origLogFilesDir);
+ deleteFile(LOGFILESDIR);
+ // copy files from testStyleRollingFile:
+ copyFileToFail("derby-0.log");
+ copyFileToFail("derby-0.log.lck");
+ // copy files from the testDefaultRollingUserConfig test
+ for (int i = 0; i < 3; i++) {
+ copyFileToFail("db-" + i + ".log");
+ deleteFile("db-" + i + ".log");
+ }
}
catch (IOException ioe) {
// We need to throw the original exception so if there
@@ -849,9 +852,29 @@ public class ErrorStreamTest extends Bas
}
}
finally{
+ // attempt to clean up
+ // first ensure we have the engine shutdown, or some
+ // files cannot be cleaned up.
+ getTestConfiguration().shutdownEngine();
File origLogFilesDir = new File(DEFAULT_DB_DIR, LOGFILESDIR);
nullFields();
removeDirectory(origLogFilesDir);
+ deleteFile("derby-0.log.lck");
+ deleteFile("derby-0.log");
+ deleteFile("derby.log");
}
}
+
+ private void copyFileToFail(String origFileName) throws IOException {
+ String failPath = PrivilegedFileOpsForTests.getAbsolutePath(getFailureFolder());
+ File origFile = new File (DEFAULT_DB_DIR, origFileName);
+ File newFile = new File (failPath, origFileName);
+ PrivilegedFileOpsForTests.copy(origFile,newFile);
+ }
+
+ // delete a file - used in cleanup when we don't care about the result
+ private void deleteFile(String origFileName) throws IOException {
+ File origFile = new File (DEFAULT_DB_DIR, origFileName);
+ PrivilegedFileOpsForTests.delete(origFile);
+ }
}