diff --git a/datamover/sourceTest/java/ch/systemsx/cisd/datamover/IncomingProcessorTest.java b/datamover/sourceTest/java/ch/systemsx/cisd/datamover/IncomingProcessorTest.java index 2302a211a91fa14981a8ed3e245ea4d25d23dc60..b585a1d8fa8006ebab60bdc34de35add7af494e4 100644 --- a/datamover/sourceTest/java/ch/systemsx/cisd/datamover/IncomingProcessorTest.java +++ b/datamover/sourceTest/java/ch/systemsx/cisd/datamover/IncomingProcessorTest.java @@ -138,12 +138,6 @@ public final class IncomingProcessorTest FileUtilities.deleteRecursively(TEST_FOLDER); TEST_FOLDER.mkdirs(); exampleScript = new File(TEST_FOLDER, EXAMPLE_SCRIPT_NAME); - if (OSUtilities.isWindows() == false) - { - Logger logger = LogFactory.getLogger(LogCategory.OPERATION, getClass()); - List<String> cmd = Arrays.asList("chmod", "755", exampleScript.getAbsolutePath()); - ProcessExecutionHelper.run(cmd, logger, logger); - } incomingDir = new File(TEST_FOLDER, INCOMING_DIR); incomingDir.mkdir(); copyInProgressDir = new File(TEST_FOLDER, COPY_IN_PROGRESS_DIR); @@ -194,7 +188,7 @@ public final class IncomingProcessorTest @Test public void testWithDataCompletedScript() throws IOException { - FileUtilities.writeToFile(exampleScript, EXAMPLE_SCRIPT); + createExampleScript(EXAMPLE_SCRIPT); final File testDataFile = new File(incomingDir, "test-data.txt"); testDataFile.createNewFile(); context.checking(new Expectations() @@ -231,8 +225,7 @@ public final class IncomingProcessorTest @Test public void testWithDataCompletedScriptWhichFailsInitially() throws IOException { - FileUtilities.writeToFile(exampleScript, EXAMPLE_SCRIPT + "\nrm -v " - + TEST_FILE.toString().replace('\\', '/')); + createExampleScript(EXAMPLE_SCRIPT + "\nrm -v " + TEST_FILE.toString().replace('\\', '/')); final File testDataFile = new File(incomingDir, "test-data.txt"); testDataFile.createNewFile(); context.checking(new Expectations() @@ -268,6 +261,17 @@ public final class IncomingProcessorTest context.assertIsSatisfied(); } + private void createExampleScript(String text) + { + FileUtilities.writeToFile(exampleScript, text); + if (OSUtilities.isWindows() == false) + { + Logger logger = LogFactory.getLogger(LogCategory.OPERATION, getClass()); + List<String> cmd = Arrays.asList("chmod", "755", exampleScript.getAbsolutePath()); + ProcessExecutionHelper.run(cmd, logger, logger); + } + } + private TimerTask getInstrumentedTimerTaskFrom(final DataMoverProcess process) { TimerTask timerTask = process.getTimerTask();