From 2e3065deb4639ae113fbf298f087ff3c38da020a Mon Sep 17 00:00:00 2001 From: tpylak <tpylak> Date: Tue, 18 Jan 2011 12:53:22 +0000 Subject: [PATCH] LMS-1966 fix unit tests SVN: 19473 --- .../JythonTopLevelDataSetRegistratorTest.java | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java index 09252dd4dce..2680d686d4f 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java @@ -113,20 +113,17 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest } @Test - public void testInvalidScriptPath() + public void testScriptPathDeletedLater() { setUpHomeDataBaseExpectations(); + String scriptPath = "foo.py"; + Properties threadProperties = createThreadProperties(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, "foo.py"); - + // test the situation where script has been deleted later + File scriptFile = new File(scriptPath); + FileUtilities.writeToFile(scriptFile, "x"); createHandler(threadProperties); + FileUtilities.delete(scriptFile); try { incomingDataSetFile = createDirectory(workingDirectory, "data_set"); @@ -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 public void testNoScriptPath() { -- GitLab