-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from TEIC/feature/junit
example converter junit tests
- Loading branch information
Showing
7 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
!*.ent | ||
!*.xsd | ||
!*.yml | ||
|
||
!test-input.*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package uk.ac.ox.oucs.oxgarage.oo; | ||
|
||
import pl.psnc.dl.ege.configuration.EGEConfigurationManager; | ||
import pl.psnc.dl.ege.exception.ConverterException; | ||
import pl.psnc.dl.ege.types.ConversionActionArguments; | ||
import pl.psnc.dl.ege.types.DataType; | ||
|
||
import java.io.*; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class OOConverterTest { | ||
private OOConverter converter; | ||
|
||
@org.junit.Before | ||
public void setUp() throws Exception { | ||
converter = new OOConverter(); | ||
} | ||
|
||
@org.junit.After | ||
public void tearDown() throws Exception { | ||
converter = null; | ||
} | ||
|
||
@org.junit.Test | ||
public void convert() throws IOException, ConverterException { | ||
//text to pdf | ||
InputStream is = new FileInputStream("src/test/resources/test-input.txt.zip"); | ||
OutputStream os = new FileOutputStream("src/test/resources/test-output.pdf.zip"); | ||
DataType inputType = new DataType("txt","text/plain"); | ||
DataType outputType = new DataType("pdf","application/pdf"); | ||
ConversionActionArguments conversionActionArguments = new ConversionActionArguments(inputType, outputType, null); | ||
String tempDir = "src/test/temp"; | ||
converter.convert(is, os, conversionActionArguments, tempDir); | ||
assertNotNull(new File("src/test/resources/test-output.pdf.zip")); | ||
is.close(); | ||
os.close(); | ||
//docx to TEI | ||
is = new FileInputStream("src/test/resources/test-input.docx.zip"); | ||
os = new FileOutputStream("src/test/resources/test-output.txt.zip"); | ||
inputType = new DataType("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"); | ||
outputType = new DataType("txt","text/plain"); | ||
conversionActionArguments = new ConversionActionArguments(inputType, outputType, null); | ||
converter.convert(is, os, conversionActionArguments, tempDir); | ||
assertNotNull(new File("src/test/resources/test-output.txt.zip")); | ||
InputStream isout = new FileInputStream("src/test/resources/test-output.txt.zip"); | ||
EGEConfigurationManager.getInstance().getStandardIOResolver().decompressStream(isout, new File("src/test/resources/test-output.txt")); | ||
//System.out.println(new String(Files. readAllBytes(Paths.get("src/test/resources/test-output.txt/result.txt")), "UTF-8")); | ||
assertNotEquals("", new String(Files.readAllBytes(Paths.get("src/test/resources/test-output.txt/result.txt")), "UTF-8")); | ||
is.close(); | ||
os.close(); | ||
isout.close(); | ||
} | ||
|
||
@org.junit.Test | ||
public void getPossibleConversions() { | ||
assertNotNull(converter.getPossibleConversions()); | ||
//System.out.println(converter.getPossibleConversions()); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.