Class PepperModuleTestHelper
- java.lang.Object
-
- org.corpus_tools.pepper.testFramework.helpers.PepperModuleTestHelper
-
- Direct Known Subclasses:
PepperModuleTest
public abstract class PepperModuleTestHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected PepperModulefixtureprotected static org.slf4j.Loggerloggerprotected org.eclipse.emf.common.util.URIresourceURIstatic StringTMP_TEST_DIR{@inheritDoc PepperTestUtil#TMP_TEST_DIR}
-
Constructor Summary
Constructors Constructor Description PepperModuleTestHelper()Creates an object of typePepperModuleTest.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancompareFiles(File file1, File file2)Compares the content of two files.booleancompareFiles(org.eclipse.emf.common.util.URI uri1, org.eclipse.emf.common.util.URI uri2)Compares the content of two files.protected PepperModulegetFixture()Returns the current fixture to test.static StringgetSrcResources(){@inheritDoc PepperTestUtil#getSrcResources()}FilegetTempPath(String testDirectory)Returns aFileobject pointing to a temporary path, where the caller can store temporary files.static FilegetTempPath_static(String testDirectory){@inheritDoc PepperTestUtil#getTempPath_static(String)}org.eclipse.emf.common.util.URIgetTempURI(String testDirectory)Returns aFileobject pointing to a temporary path, where the caller can store temporary files.static StringgetTestResources(){@inheritDoc PepperTestUtil#getTestResources()}voidinitialize()Initializes this object.protected voidsetFixture(PepperModule fixture)Sets the current fixture to test.voidsetResourcesURI(org.eclipse.emf.common.util.URI resourceURI)Sets the path to resources folder for module.voidstart()This methods starts the processing of Pepper in the development environment.
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
resourceURI
protected org.eclipse.emf.common.util.URI resourceURI
-
fixture
protected PepperModule fixture
-
TMP_TEST_DIR
public static String TMP_TEST_DIR
{@inheritDoc PepperTestUtil#TMP_TEST_DIR}
-
-
Constructor Detail
-
PepperModuleTestHelper
public PepperModuleTestHelper()
Creates an object of typePepperModuleTest. To initialize it, the overridable methodinitialize()is called.
-
-
Method Detail
-
setFixture
protected void setFixture(PepperModule fixture)
Sets the current fixture to test.- Parameters:
fixture- object to test, derived fromPepperModule
-
getFixture
protected PepperModule getFixture()
Returns the current fixture to test.- Returns:
- object to test, derived from
PepperModule
-
initialize
public void initialize()
Initializes this object. This means:- the resource folder
setResourcesURI(URI)is set to mavens default 'src/main/resources'
- the resource folder
-
getTempURI
public org.eclipse.emf.common.util.URI getTempURI(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
-
getTempPath
public File getTempPath(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
-
getTempPath_static
public static File getTempPath_static(String testDirectory)
{@inheritDoc PepperTestUtil#getTempPath_static(String)}
-
getTestResources
public static String getTestResources()
{@inheritDoc PepperTestUtil#getTestResources()}
-
getSrcResources
public static String getSrcResources()
{@inheritDoc PepperTestUtil#getSrcResources()}
-
start
public void start()
This methods starts the processing of Pepper in the development environment. 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);
- Create
-
setResourcesURI
public void setResourcesURI(org.eclipse.emf.common.util.URI resourceURI)
Sets the path to resources folder for module.- Parameters:
resourceURI- URI with path
-
compareFiles
public boolean compareFiles(org.eclipse.emf.common.util.URI uri1, org.eclipse.emf.common.util.URI uri2) throws IOExceptionCompares the content of two files. Iff they are exactly the same, than true will be returned. False otherwise.- Parameters:
uri1- first file to compareuri2- second file to compare- Returns:
- true, iff files are exactly the same
- Throws:
IOException
-
compareFiles
public boolean compareFiles(File file1, File file2) throws IOException
Compares the content of two files. Iff they are exactly the same, than true will be returned. False otherwise.- Parameters:
file1- first file to comparefile2- second file to compare- Returns:
- true, iff files are exactly the same
- Throws:
IOExceptionIOException
-
-