Skip to content
Snippets Groups Projects
Commit 2e3065de authored by tpylak's avatar tpylak
Browse files

LMS-1966 fix unit tests

SVN: 19473
parent 5e8d9762
No related branches found
No related tags found
No related merge requests found
...@@ -113,20 +113,17 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest ...@@ -113,20 +113,17 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest
} }
@Test @Test
public void testInvalidScriptPath() public void testScriptPathDeletedLater()
{ {
setUpHomeDataBaseExpectations(); setUpHomeDataBaseExpectations();
String scriptPath = "foo.py";
Properties threadProperties = createThreadProperties(scriptPath);
Properties threadProperties = new Properties(); // test the situation where script has been deleted later
threadProperties.put(ThreadParameters.INCOMING_DIR, "incoming"); File scriptFile = new File(scriptPath);
threadProperties.put(ThreadParameters.INCOMING_DATA_COMPLETENESS_CONDITION, FileUtilities.writeToFile(scriptFile, "x");
ThreadParameters.INCOMING_DATA_COMPLETENESS_CONDITION_MARKER_FILE);
threadProperties.put(ThreadParameters.DELETE_UNIDENTIFIED_KEY, "false");
threadProperties.put(IStorageProcessor.STORAGE_PROCESSOR_KEY,
MockStorageProcessor.class.getName());
threadProperties.put(JythonTopLevelDataSetHandler.SCRIPT_PATH_KEY, "foo.py");
createHandler(threadProperties); createHandler(threadProperties);
FileUtilities.delete(scriptFile);
try try
{ {
incomingDataSetFile = createDirectory(workingDirectory, "data_set"); incomingDataSetFile = createDirectory(workingDirectory, "data_set");
...@@ -146,6 +143,37 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest ...@@ -146,6 +143,37 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest
} }
} }
@Test
public void testScriptPathMissing()
{
setUpHomeDataBaseExpectations();
String scriptPath = "foo.py";
Properties threadProperties = createThreadProperties(scriptPath);
// it should not be possible to create a handler if script does not exist
try
{
createHandler(threadProperties);
fail("The script should does not exist");
} catch (ConfigurationFailureException ex)
{
assertEquals(ex.getMessage(), "Script file 'foo.py' does not exist!");
}
}
private Properties createThreadProperties(String scriptPath)
{
Properties threadProperties = new Properties();
threadProperties.put(ThreadParameters.INCOMING_DIR, "incoming");
threadProperties.put(ThreadParameters.INCOMING_DATA_COMPLETENESS_CONDITION,
ThreadParameters.INCOMING_DATA_COMPLETENESS_CONDITION_MARKER_FILE);
threadProperties.put(ThreadParameters.DELETE_UNIDENTIFIED_KEY, "false");
threadProperties.put(IStorageProcessor.STORAGE_PROCESSOR_KEY,
MockStorageProcessor.class.getName());
threadProperties.put(JythonTopLevelDataSetHandler.SCRIPT_PATH_KEY, scriptPath);
return threadProperties;
}
@Test @Test
public void testNoScriptPath() public void testNoScriptPath()
{ {
......
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