testDirectory
.
- * @param testDirectory last part of the temporary path
- * @return a file object locating to a temporary folder, where files can be stored temporarily
+ * {@inheritDoc PepperTestUtil#getTempPath_static(String)}
*/
public static File getTempPath_static(String testDirectory){
- if ( (testDirectory== null)||
- (testDirectory.isEmpty())){
- throw new PepperModuleTestException("Cannot return a temporary directory, since the given last part is empty.");
- }
- File retVal= null;
- retVal= PepperUtil.getTempTestFile(TMP_TEST_DIR+"/"+testDirectory);
- return(retVal);
+ return(PepperTestUtil.getTempPath_static(testDirectory));
}
/**
- * Returns a default test folder, where to find resources for tests. When using the default
- * maven structure, this folder is located at 'src/test/resources/'.
- * @return a folder where to find test resources
+ * {@inheritDoc PepperTestUtil#getTestResources()}
*/
public static String getTestResources(){
- return("src/test/resources/");
+ return(PepperTestUtil.getTestResources());
}
/**
- * Returns a default test folder, where to find resources for tests. When using the default
- * maven structure, this folder is located at 'src/test/resources/'.
- * @return a folder where to find test resources
+ * {@inheritDoc PepperTestUtil#getSrcResources()}
*/
public static String getSrcResources(){
- return("src/main/resources/");
+ return(PepperTestUtil.getSrcResources());
}
/**
@@ -182,112 +151,12 @@ public static String getSrcResources(){
*
*
*/
- public void start()
- {
- if (this.getFixture()== null)
- throw new PepperModuleTestException("Cannot start Pepper module, because the fixture is not set.");
-
- if (this.getFixture().getSaltProject()== null)
- this.getFixture().setSaltProject(SaltFactory.eINSTANCE.createSaltProject());
-
- File tmpFolder= getTempPath("pepperModuleTest");
-
- PepperImpl pepper= new PepperImpl();
- PepperConfiguration conf= new PepperConfiguration();
- conf.setProperty(PepperConfiguration.PROP_MEMORY_POLICY, MEMORY_POLICY.MODERATE.toString());
- pepper.setConfiguration(conf);
- PepperJob job= pepper.getJob(pepper.createJob());
-
- if (!(job instanceof PepperJobImpl))
- throw new PepperModuleTestException("Cannot start Pepper module test, because '"+PepperJob.class+"' is not of type '"+PepperJobImpl.class+"'. ");
-
- ((PepperJobImpl)job).setSaltProject(getFixture().getSaltProject());
-
- CorpusDesc corpusDesc;
- FormatDesc formatDesc;
-
- Step fixtureStep= null;
- fixtureStep= new Step("fixture_step");
- fixtureStep.setModuleType(getFixture().getModuleType());
- fixtureStep.setName(getFixture().getName());
- fixtureStep.setVersion(getFixture().getVersion());
- if (getFixture() instanceof PepperImporter){
- fixtureStep.setCorpusDesc(((PepperImporter)getFixture()).getCorpusDesc());
- }else if (getFixture() instanceof PepperExporter){
- fixtureStep.setCorpusDesc(((PepperExporter)getFixture()).getCorpusDesc());
- }
- fixtureStep.setPepperModule(getFixture());
- ((PepperJobImpl)job).addStep(fixtureStep);
-
- URI dummyResourceURI= URI.createFileURI(new File(System.getProperty("java.io.tmpdir")).getAbsolutePath());
-
- //define export step
- Step exportStep= new Step("doNothing_export_step");
- exportStep.setModuleType(MODULE_TYPE.EXPORTER);
- exportStep.setName(DoNothingImporter.MODULE_NAME);
- PepperExporter exporter= new DoNothingExporter();
- exporter.setResources(dummyResourceURI);
- exportStep.setPepperModule(exporter);
-
- corpusDesc= new CorpusDesc();
- corpusDesc.setCorpusPath(URI.createFileURI(tmpFolder.getAbsolutePath()));
- formatDesc= new FormatDesc();
- formatDesc.setFormatName(DoNothingImporter.FORMAT_NAME);
- formatDesc.setFormatVersion(DoNothingImporter.FORMAT_VERSION);
- corpusDesc.setFormatDesc(formatDesc);
- exportStep.setCorpusDesc(corpusDesc);
- exporter.setCorpusDesc(corpusDesc);
- //define export step
-
- //define import step
- ListtestDirectory
.
+ * @param testDirectory last part of the temporary path
+ * @return a file object locating to a temporary folder, where files can be stored temporarily
+ */
+ public static File getTempPath_static(String testDirectory){
+ if ( (testDirectory== null)||
+ (testDirectory.isEmpty())){
+ throw new PepperModuleTestException("Cannot return a temporary directory, since the given last part is empty.");
+ }
+ File retVal= null;
+ retVal= PepperUtil.getTempTestFile(TMP_TEST_DIR+"/"+testDirectory);
+ return(retVal);
+ }
+
+ /**
+ * Returns a default test folder, where to find resources for tests. When using the default
+ * maven structure, this folder is located at 'src/test/resources/'.
+ * @return a folder where to find test resources
+ */
+ public static String getSrcResources(){
+ return("src/main/resources/");
+ }
+ /**
+ * Returns a default test folder, where to find resources for tests. When using the default
+ * maven structure, this folder is located at 'src/test/resources/'.
+ * @return a folder where to find test resources
+ */
+ public static String getTestResources(){
+ return("src/test/resources/");
+ }
+ /**
+ * Creates an alibi {@link Step} for the method {@link #start(Collection)}.
+ *
+ * @param createAlibiImporter
+ * @return
+ */
+ private static Step createAlibiStep(boolean createAlibiImporter) {
+ URI dummyResourceURI = URI.createFileURI(new File(System.getProperty("java.io.tmpdir")).getAbsolutePath());
+ FormatDesc formatDesc;
+
+ // set tmp folder
+ File tmpFolder = PepperModuleTest.getTempPath_static("pepperModuleTest");
+
+ Step step = null;
+ CorpusDesc corpusDesc = new CorpusDesc();
+ corpusDesc.setCorpusPath(URI.createFileURI(tmpFolder.getAbsolutePath()));
+ formatDesc = new FormatDesc();
+ formatDesc.setFormatName(DoNothingImporter.FORMAT_NAME);
+ formatDesc.setFormatVersion(DoNothingImporter.FORMAT_VERSION);
+ corpusDesc.setFormatDesc(formatDesc);
+
+ if (createAlibiImporter) {
+ step = new Step("doNothing_import_step");
+ PepperImporter importer = new DoNothingImporter();
+ importer.setResources(dummyResourceURI);
+ importer.setCorpusDesc(corpusDesc);
+ step.setPepperModule(importer);
+ step.setModuleType(MODULE_TYPE.IMPORTER);
+ } else {
+ step = new Step("doNothing_export_step");
+ PepperExporter exporter = new DoNothingExporter();
+ exporter.setCorpusDesc(corpusDesc);
+ exporter.setResources(dummyResourceURI);
+ step.setPepperModule(exporter);
+ step.setModuleType(MODULE_TYPE.EXPORTER);
+ }
+ step.setCorpusDesc(corpusDesc);
+ step.setName(DoNothingImporter.MODULE_NAME);
+
+ return (step);
+ }
+
+ /**
+ * This methods starts the processing of Pepper in the development
+ * environment for a set of Pepper modules. This enables the test of
+ * multiple modules at once, for instance the import and export of data to
+ * check no data is lost. In case of the fixture is {@link PepperImporter},
+ * first the method
+ * {@link PepperImporter#importCorpusStructure(SCorpusGraph)} is called. For
+ * all kinds of fixture, the method
+ * {@link PepperModule#start(de.hu_berlin.german.korpling.saltnpepper.salt.saltCore.SElementId)}
+ * is called for each {@link SDocument} object contained in the variable
+ * {@link PepperModule#getSaltProject()}. This method will wait, until each
+ * {@link ModuleControllerImpl} return having finished the process. + * this.getFixture().getSaltProject().getSCorpusGraphs().add(importedCorpusGraph); + * this.getFixture().importCorpusStructure(importedCorpusGraph); + *+ * + *