Class PepperTestUtil
- java.lang.Object
-
- org.corpus_tools.pepper.testFramework.PepperTestUtil
-
public class PepperTestUtil extends Object
This class offers some static fields and methods for testingPepperModuleobjects.- Author:
- florian
-
-
Field Summary
Fields Modifier and Type Field Description static StringTMP_TEST_DIRName of the directory where tests for Pepper and Pepper modules can be stored.
-
Constructor Summary
Constructors Constructor Description PepperTestUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PeppercreateDefaultPepper()static StringgetSrcResources()Returns a default test folder, where to find resources for tests.static FilegetTempPath_static(String testDirectory)Returns aFileobject pointing to a temporary path, where the caller can store temporary files.static StringgetTestResources()Returns a default test folder, where to find resources for tests.static PepperJobprepareFixturesAndCreateJob(Pepper pepper, Collection<? extends PepperModule> fixtures)static <T extends PepperModule>
voidrunPepperForTest(T... fixtures)static voidstart(Collection<? extends PepperModule> fixtures)This methods starts the processing of Pepper in the development environment for a set of Pepper modules.static voidstart(Pepper pepper, Collection<? extends PepperModule> fixtures)
-
-
-
Field Detail
-
TMP_TEST_DIR
public static String TMP_TEST_DIR
Name of the directory where tests for Pepper and Pepper modules can be stored.
-
-
Method Detail
-
getTempPath_static
public static File getTempPath_static(String testDirectory)
Returns aFileobject pointing to a temporary path, where the caller can store temporary files. The temporary path is located in the temporary directory provided by the underlying os. The resulting directory is located in TEMP_PATH_BY_OS//testDirectory.- Parameters:
testDirectory- last part of the temporary path- Returns:
- a file object locating to a temporary folder, where files can be stored temporarily
-
getSrcResources
public static String getSrcResources()
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/'.- Returns:
- a folder where to find test resources
-
getTestResources
public static String 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/'.- Returns:
- a folder where to find test resources
-
createDefaultPepper
public static Pepper createDefaultPepper()
-
start
public static void start(Collection<? extends PepperModule> fixtures)
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 isPepperImporter, first the methodPepperImporter.importCorpusStructure(SCorpusGraph)is called. For all kinds of fixture, the methodPepperModule.start(org.corpus_tools.salt.graph.Identifier)is called for eachSDocumentobject contained in the variablePepperModule.getSaltProject(). This method will wait, until eachModuleControllerImplreturn having finished the process.
To create a test using this method do the following:
- Create
CorpusDefinitionand add it to this object and set itsFormatDefinitionand corpus path - Create a
SCorpusGraphobject as the one to be filled and add it withgetFixture().getSaltProject().getCorpusGraphs().add(importedCorpusGraph); getFixture().importCorpusStructure(importedCorpusGraph);
- Parameters:
fixtures- the fixture modules
- Create
-
runPepperForTest
@SafeVarargs public static <T extends PepperModule> void runPepperForTest(T... fixtures)
- See Also:
start(Collection)
-
prepareFixturesAndCreateJob
public static PepperJob prepareFixturesAndCreateJob(Pepper pepper, Collection<? extends PepperModule> fixtures)
-
start
public static void start(Pepper pepper, Collection<? extends PepperModule> fixtures)
- Parameters:
pepper- a pepper instance to be used- See Also:
start(Collection)
-
-