Class ArchiveTestResourceProvider
java.lang.Object
de.gebit.integrity.runner.providers.AbstractTestResourceProvider
de.gebit.integrity.runner.providers.ArchiveTestResourceProvider
- All Implemented Interfaces:
TestResourceProvider
This
TestResourceProvider can read archive files (zip/jar format) and provide the Integrity script files
within these archives transparently to the Test Runner. It can even read archives within archives, up to an arbitrary
depth.- Author:
- Rene Schneider - initial API and implementation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTest resource located within one or multiple archives. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe ending of jar archives.static final StringThe ending of zip archives.Fields inherited from class de.gebit.integrity.runner.providers.AbstractTestResourceProvider
INTEGRITY_TEST_FILES_SUFFIX, resourceFiles -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArchive(File anArchiveFile, boolean aRecursiveFlag) Adds an archive (all contained .integrity files) to the resource provider.protected voidaddArchive(ZipInputStream anArchiveInputStream, String aPrefix, boolean aRecursiveFlag, Stack<String> anArchiveFileNameStack) Recursive-enabled variant ofaddArchive(File, boolean).voidcloseResource(TestResource aResourceName, InputStream aResourceStream) Closes a specified resources' stream (and all the stuff opened for this stream in the background).protected booleanfindFileInZipInputStream(ZipInputStream aStream, String aFileName) Searches the givenZipInputStreamfor an entry, then stops.openResource(TestResource aResourceName) Opens a specific named resource.Methods inherited from class de.gebit.integrity.runner.providers.AbstractTestResourceProvider
addResource, createAndAddResource, createResource, getClassLoader, getResourceNames, setClassLoader
-
Field Details
-
ARCHIVE_ENDING_ZIP
The ending of zip archives.- See Also:
-
ARCHIVE_ENDING_JAR
The ending of jar archives.- See Also:
-
-
Constructor Details
-
ArchiveTestResourceProvider
public ArchiveTestResourceProvider()
-
-
Method Details
-
addArchive
Adds an archive (all contained .integrity files) to the resource provider.- Parameters:
anArchiveFile- the archive file to addaRecursiveFlag- whether other archives inside this archive shall be added recursively- Throws:
IOException
-
addArchive
protected void addArchive(ZipInputStream anArchiveInputStream, String aPrefix, boolean aRecursiveFlag, Stack<String> anArchiveFileNameStack) throws IOException Recursive-enabled variant ofaddArchive(File, boolean).- Parameters:
anArchiveInputStream- the archive input stream to read fromaPrefix- the prefix to prepend in front of the filename inside the archiveaRecursiveFlag- a flag whether recursive invocation is desired- Throws:
IOException
-
openResource
Description copied from interface:TestResourceProviderOpens a specific named resource. This should return anInputStreamat the start of the data of the respective resources, and it is only expected to work if the resource is one of those enumerated by a call toTestResourceProvider.getResourceNames().- Parameters:
aResourceName- the resource to be opened- Returns:
- an
InputStreamto read the resource - Throws:
IOException
-
closeResource
public void closeResource(TestResource aResourceName, InputStream aResourceStream) throws IOException Description copied from interface:TestResourceProviderCloses a specified resources' stream (and all the stuff opened for this stream in the background).- Parameters:
aResourceName- the resource to be closedaResourceStream- the resource stream to close- Throws:
IOException
-
findFileInZipInputStream
protected boolean findFileInZipInputStream(ZipInputStream aStream, String aFileName) throws IOException Searches the givenZipInputStreamfor an entry, then stops. This changes the active entry in the stream to the entry to find (if found) or no entry (if not found).- Parameters:
aStream- the stream to search inaFileName- the entry name- Returns:
- true if the entry was found, false if not
- Throws:
IOException
-