From 8adfe10c4dd116690a9644dbd5bae9ae4de6e49f Mon Sep 17 00:00:00 2001 From: kaloyane <kaloyane> Date: Wed, 13 Jul 2011 07:13:51 +0000 Subject: [PATCH] minor: add a possibility to specify python.path extensions (used when testing modularized dropboxes) SVN: 22103 --- .../AbstractJythonDataSetHandlerTest.java | 80 +++++++++++-------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/AbstractJythonDataSetHandlerTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/AbstractJythonDataSetHandlerTest.java index 99bd9f93553..79c4c14261b 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/AbstractJythonDataSetHandlerTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/AbstractJythonDataSetHandlerTest.java @@ -125,39 +125,6 @@ public abstract class AbstractJythonDataSetHandlerTest extends AbstractFileSyste context.assertIsSatisfied(); } - private Properties createThreadProperties(String scriptPath, - String validationScriptPropertyOrNull) - { - 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(IStorageProcessorTransactional.STORAGE_PROCESSOR_KEY, - MockStorageProcessor.class.getName()); - threadProperties.put(JythonTopLevelDataSetHandler.SCRIPT_PATH_KEY, scriptPath); - if (null != validationScriptPropertyOrNull) - { - threadProperties.put(ch.systemsx.cisd.etlserver.ThreadParameters.VALIDATION_SCRIPT_KEY, - validationScriptPropertyOrNull); - } - threadProperties.setProperty(DataSetRegistrationService.STAGING_DIR, - stagingDirectory.getPath()); - return threadProperties; - } - - protected Properties createThreadPropertiesRelativeToScriptsFolder(String scriptPath) - { - return createThreadProperties(getRegistrationScriptsFolderPath() + scriptPath, null); - } - - protected Properties createThreadPropertiesRelativeToScriptsFolder(String scriptPath, - String validationScriptPath) - { - return createThreadProperties(getRegistrationScriptsFolderPath() + scriptPath, - validationScriptPath); - } - protected File createDirectory(File parentDir, String directoryName) { final File file = new File(parentDir, directoryName); @@ -172,7 +139,7 @@ public abstract class AbstractJythonDataSetHandlerTest extends AbstractFileSyste handler = new TestingDataSetHandler(globalState, registrationShouldFail, - shouldReThrowException); + shouldReThrowException); } protected TopLevelDataSetRegistratorGlobalState createGlobalState(Properties threadProperties) @@ -201,6 +168,51 @@ public abstract class AbstractJythonDataSetHandlerTest extends AbstractFileSyste } }); } + /** + * adds an extension to the Jython Path, so that all libraries in it will be visible to the + * Jython environment. + */ + protected void extendJythonLibPath(String pathExtension) + { + final String JYTHON_PATH_PROPNAME = "python.path"; + String pythonPath = System.getProperty(JYTHON_PATH_PROPNAME, ""); + String extendedPath = pythonPath + File.pathSeparator + pathExtension; + System.setProperty("python.path", extendedPath); + } + + protected Properties createThreadPropertiesRelativeToScriptsFolder(String scriptPath) + { + return createThreadProperties(getRegistrationScriptsFolderPath() + scriptPath, null); + } + + protected Properties createThreadPropertiesRelativeToScriptsFolder(String scriptPath, + String validationScriptPath) + { + return createThreadProperties(getRegistrationScriptsFolderPath() + scriptPath, + validationScriptPath); + } + + private Properties createThreadProperties(String scriptPath, + String validationScriptPropertyOrNull) + { + 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(IStorageProcessorTransactional.STORAGE_PROCESSOR_KEY, + MockStorageProcessor.class.getName()); + threadProperties.put(JythonTopLevelDataSetHandler.SCRIPT_PATH_KEY, scriptPath); + if (null != validationScriptPropertyOrNull) + { + threadProperties.put(ch.systemsx.cisd.etlserver.ThreadParameters.VALIDATION_SCRIPT_KEY, + validationScriptPropertyOrNull); + } + threadProperties.setProperty(DataSetRegistrationService.STAGING_DIR, + stagingDirectory.getPath()); + return threadProperties; + } + public static final class MockStorageProcessor implements IStorageProcessorTransactional { -- GitLab