Skip to content
Snippets Groups Projects
Commit 298c3fb7 authored by brinn's avatar brinn
Browse files

fix: strange test failure, make test robust

SVN: 7474
parent c43b34e2
No related branches found
No related tags found
No related merge requests found
...@@ -88,8 +88,6 @@ public final class IncomingProcessorTest ...@@ -88,8 +88,6 @@ public final class IncomingProcessorTest
private static final String EXAMPLE_SCRIPT = "echo hello world"; private static final String EXAMPLE_SCRIPT = "echo hello world";
private static final File TEST_FILE = new File(TEST_FOLDER, "blabla.txt");
private BufferedAppender logRecorder; private BufferedAppender logRecorder;
private Mockery context; private Mockery context;
...@@ -301,7 +299,7 @@ public final class IncomingProcessorTest ...@@ -301,7 +299,7 @@ public final class IncomingProcessorTest
@Test @Test
public void testWithDataCompletedScriptWhichFailsInitially() throws IOException public void testWithDataCompletedScriptWhichFailsInitially() throws IOException
{ {
createExampleScript(EXAMPLE_SCRIPT + "\nrm -v " + TEST_FILE.toString().replace('\\', '/')); createExampleScript("exit 1");
final File testDataFile = new File(incomingDir, "test-data.txt"); final File testDataFile = new File(incomingDir, "test-data.txt");
testDataFile.createNewFile(); testDataFile.createNewFile();
final File markerFile = new File(incomingDir, MarkerFile.createRequiresDeletionBeforeCreationMarker().getName()); final File markerFile = new File(incomingDir, MarkerFile.createRequiresDeletionBeforeCreationMarker().getName());
...@@ -318,7 +316,11 @@ public final class IncomingProcessorTest ...@@ -318,7 +316,11 @@ public final class IncomingProcessorTest
markerFile.renameTo(result); markerFile.renameTo(result);
return result; return result;
} }
}); });
one(mover).tryMove(testDataFile, copyCompleteDir, "");
will(returnValue(new File(copyCompleteDir, testDataFile.getName())));
} }
}); });
...@@ -339,7 +341,7 @@ public final class IncomingProcessorTest ...@@ -339,7 +341,7 @@ public final class IncomingProcessorTest
logRecorder.resetLogContent(); logRecorder.resetLogContent();
operationAppender.reset(); operationAppender.reset();
TEST_FILE.createNewFile(); createExampleScript("exit 0"); // now the script will run fine
dataMoverTimerTask.run(); // 4. round finds changed status, thus log dataMoverTimerTask.run(); // 4. round finds changed status, thus log
assertTrue(logRecorder.getLogContent().length() > 0); assertTrue(logRecorder.getLogContent().length() > 0);
operationAppender.verifyLogHasHappened(); operationAppender.verifyLogHasHappened();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment