Java Code Examples for org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests#getFileOutputStream()
The following examples show how to use
org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests#getFileOutputStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: 919148_ReplicationRun_0_s.java From coming with MIT License | 4 votes |
/** * Run the test. Extra logic in addition to BaseTestCase's similar logic, * to save derby.log and database files for replication directories if a * failure happens. */ public void runBare() throws Throwable { try { super.runBare(); } catch (Throwable running) { // Copy the master and slave's derby.log file and databases // PrintWriter stackOut = null; try { String failPath = PrivilegedFileOpsForTests. getAbsolutePath(getFailureFolder()); stackOut = new PrintWriter( PrivilegedFileOpsForTests.getFileOutputStream( new File(failPath, ERRORSTACKTRACEFILE), true)); String[] replPaths = new String[]{masterDbSubPath, slaveDbSubPath}; for (int i=0; i < 2; i++) { // Copy the derby.log file. // File origLog = new File(replPaths[i], DERBY_LOG); File newLog = new File(failPath, replPaths[i] + "-" + DERBY_LOG); PrivilegedFileOpsForTests.copy(origLog, newLog); // Copy the database. // String dbName = TestConfiguration.getCurrent(). getDefaultDatabaseName(); File dbDir = new File(replPaths[i], dbName ); File newDbDir = new File(failPath, replPaths[i] + "-" + dbName); PrivilegedFileOpsForTests.copy(dbDir,newDbDir); } } catch (IOException ioe) { // We need to throw the original exception so if there // is an exception saving the db or derby.log we will print it // and additionally try to log it to file. BaseTestCase.printStackTrace(ioe); if (stackOut != null) { stackOut.println("Copying db_slave/db_master's " + DERBY_LOG + " or database failed:"); ioe.printStackTrace(stackOut); stackOut.println(); } } finally { if (stackOut != null) { stackOut.close(); } // Let JUnit take over throw running; } } }
Example 2
Source File: 919148_ReplicationRun_0_t.java From coming with MIT License | 4 votes |
/** * Run the test. Extra logic in addition to BaseTestCase's similar logic, * to save derby.log and database files for replication directories if a * failure happens. */ public void runBare() throws Throwable { try { super.runBare(); } catch (Throwable running) { // Copy the master and slave's derby.log file and databases // PrintWriter stackOut = null; try { String failPath = PrivilegedFileOpsForTests. getAbsolutePath(getFailureFolder()); stackOut = new PrintWriter( PrivilegedFileOpsForTests.getFileOutputStream( new File(failPath, ERRORSTACKTRACEFILE), true)); String[] replPaths = new String[]{masterDbSubPath, slaveDbSubPath}; for (int i=0; i < 2; i++) { // Copy the derby.log file. // File origLog = new File(replPaths[i], DERBY_LOG); File newLog = new File(failPath, replPaths[i] + "-" + DERBY_LOG); PrivilegedFileOpsForTests.copy(origLog, newLog); // Copy the database. // String dbName = TestConfiguration.getCurrent(). getDefaultDatabaseName(); File dbDir = new File(replPaths[i], dbName ); File newDbDir = new File(failPath, replPaths[i] + "-" + dbName); PrivilegedFileOpsForTests.copy(dbDir,newDbDir); } } catch (IOException ioe) { // We need to throw the original exception so if there // is an exception saving the db or derby.log we will print it // and additionally try to log it to file. BaseTestCase.printStackTrace(ioe); if (stackOut != null) { stackOut.println("Copying db_slave/db_master's " + DERBY_LOG + " or database failed:"); ioe.printStackTrace(stackOut); stackOut.println(); } } finally { if (stackOut != null) { stackOut.close(); } // Let JUnit take over throw running; } } }
Example 3
Source File: 919148_ReplicationRun_0_s.java From gumtree-spoon-ast-diff with Apache License 2.0 | 4 votes |
/** * Run the test. Extra logic in addition to BaseTestCase's similar logic, * to save derby.log and database files for replication directories if a * failure happens. */ public void runBare() throws Throwable { try { super.runBare(); } catch (Throwable running) { // Copy the master and slave's derby.log file and databases // PrintWriter stackOut = null; try { String failPath = PrivilegedFileOpsForTests. getAbsolutePath(getFailureFolder()); stackOut = new PrintWriter( PrivilegedFileOpsForTests.getFileOutputStream( new File(failPath, ERRORSTACKTRACEFILE), true)); String[] replPaths = new String[]{masterDbSubPath, slaveDbSubPath}; for (int i=0; i < 2; i++) { // Copy the derby.log file. // File origLog = new File(replPaths[i], DERBY_LOG); File newLog = new File(failPath, replPaths[i] + "-" + DERBY_LOG); PrivilegedFileOpsForTests.copy(origLog, newLog); // Copy the database. // String dbName = TestConfiguration.getCurrent(). getDefaultDatabaseName(); File dbDir = new File(replPaths[i], dbName ); File newDbDir = new File(failPath, replPaths[i] + "-" + dbName); PrivilegedFileOpsForTests.copy(dbDir,newDbDir); } } catch (IOException ioe) { // We need to throw the original exception so if there // is an exception saving the db or derby.log we will print it // and additionally try to log it to file. BaseTestCase.printStackTrace(ioe); if (stackOut != null) { stackOut.println("Copying db_slave/db_master's " + DERBY_LOG + " or database failed:"); ioe.printStackTrace(stackOut); stackOut.println(); } } finally { if (stackOut != null) { stackOut.close(); } // Let JUnit take over throw running; } } }
Example 4
Source File: 919148_ReplicationRun_0_t.java From gumtree-spoon-ast-diff with Apache License 2.0 | 4 votes |
/** * Run the test. Extra logic in addition to BaseTestCase's similar logic, * to save derby.log and database files for replication directories if a * failure happens. */ public void runBare() throws Throwable { try { super.runBare(); } catch (Throwable running) { // Copy the master and slave's derby.log file and databases // PrintWriter stackOut = null; try { String failPath = PrivilegedFileOpsForTests. getAbsolutePath(getFailureFolder()); stackOut = new PrintWriter( PrivilegedFileOpsForTests.getFileOutputStream( new File(failPath, ERRORSTACKTRACEFILE), true)); String[] replPaths = new String[]{masterDbSubPath, slaveDbSubPath}; for (int i=0; i < 2; i++) { // Copy the derby.log file. // File origLog = new File(replPaths[i], DERBY_LOG); File newLog = new File(failPath, replPaths[i] + "-" + DERBY_LOG); PrivilegedFileOpsForTests.copy(origLog, newLog); // Copy the database. // String dbName = TestConfiguration.getCurrent(). getDefaultDatabaseName(); File dbDir = new File(replPaths[i], dbName ); File newDbDir = new File(failPath, replPaths[i] + "-" + dbName); PrivilegedFileOpsForTests.copy(dbDir,newDbDir); } } catch (IOException ioe) { // We need to throw the original exception so if there // is an exception saving the db or derby.log we will print it // and additionally try to log it to file. BaseTestCase.printStackTrace(ioe); if (stackOut != null) { stackOut.println("Copying db_slave/db_master's " + DERBY_LOG + " or database failed:"); ioe.printStackTrace(stackOut); stackOut.println(); } } finally { if (stackOut != null) { stackOut.close(); } // Let JUnit take over throw running; } } }