From 1528e3c9f0cbc2a7a14f09d5606d0025c2e0b028 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 11:22:36 +0100 Subject: [PATCH 01/11] example converter junit tests --- .gitignore | 2 +- pom.xml | 7 +++ .../ox/oucs/oxgarage/oo/OOConverterTest.java | 53 ++++++++++++++++++ src/test/resources/test-input.docx.zip | Bin 0 -> 12722 bytes src/test/resources/test-input.txt.zip | Bin 0 -> 347 bytes 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java create mode 100644 src/test/resources/test-input.docx.zip create mode 100644 src/test/resources/test-input.txt.zip diff --git a/.gitignore b/.gitignore index a6f01bd..ea58c5e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ !*.ent !*.xsd !*.yml - +!test-input.*.zip diff --git a/pom.xml b/pom.xml index f76cb2f..01c30c2 100644 --- a/pom.xml +++ b/pom.xml @@ -211,6 +211,13 @@ 0.6 compile + + + junit + junit + 4.13.2 + test + diff --git a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java new file mode 100644 index 0000000..b47fbb1 --- /dev/null +++ b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java @@ -0,0 +1,53 @@ +package uk.ac.ox.oucs.oxgarage.oo; + +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 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); + converter.convert(is, os, conversionActionArguments); + 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); + assertNotNull(new File("src/test/resources/test-output.txt.zip")); + is.close(); + os.close(); + } + + @org.junit.Test + public void getPossibleConversions() { + assertNotNull(converter.getPossibleConversions()); + System.out.println(converter.getPossibleConversions()); + } +} \ No newline at end of file diff --git a/src/test/resources/test-input.docx.zip b/src/test/resources/test-input.docx.zip new file mode 100644 index 0000000000000000000000000000000000000000..62a6ea4a3b6fa53aa8bd172f46655e299d3d071f GIT binary patch literal 12722 zcmZ{rQ*0&-)UDszwr$&-+P0>)+o^5awvDOVscjo?ZM*;X=OpLiBxm2OwUd3nvyx{i z$%28Sg8=~0fD#Qowf^(hUR)Lcz>yaKfB^siu4XQ-jHV7I9#^_9uBL{ladw*{Lv0+5 zcAE;6<8ro}Ssuol$3ty)cIG`Fy5Aiqwl5vN_W6Q_J$_F;_1Cp8RYxTOB1!;aVq(C( zX-f*=`yAqn#g!nY7XM7}>zzLTItkod7_fOe#VU2@TC0i4S!D&6Cx`a(jVj;;nf9#R ztz_aWk65LxPzo1+=H#Ex?T>NNx?N07h=t$Mvd*+*`16;~d+@EdjYFz)KyJ0BN%-}= zzra|_99f3_cwhED2a(E-jiYMR}d1X*6Ci+qHD*4=n z!linw4+x8inyu)udrMe5^&!y`PKY-u57X^w^<81ko<)=@;{OhsFnd6NCH*As1lJ)* zf(rhq(15*sKIl6W>~-7;p0y301)L3DY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y=)1uwKCTJGcOd)m~7AO$gp>%n(faW0zYU)S5TKVIQ;d8^q_mxfr# z9`=sZdy-E-j7xnNfI0N{HFke=?hD$EO&mV!pU$9nR7u;tGcdt1ins$XTSLDZSi8xNw^UUS z5{XfHRp@MH1hr)1V`cFsa996JH%aQyk z%>K8Lhe_W~6;S{1PA!>|A*d1&Eky>WFz$oR<}J*g4IXg=AlGo3pI`ii9Z^)bb9xtk^2on2#guFfPxkRK10{~t`mbGU$a+t zIpe+rZtK0>k$)h?pkI-2tG)@pSEnhV{lSPJ-{rGs9p?PE4+1{9EO`=kTgpGl!2I=R z;~%&nnft%p42O1g-(|1vcRvPTKZ#tyJ_SCRI?f$F0Z-Y^C%Xkd?|G=7y9K_#{Z#+_ z2fcMBJ#ujse#5n(yg6KleL{Y%N|P+?7O>FxXQ%yO{-m=X-ozV-J!OmCbDj2G`v2rL zgJ{b0Q3b6+!&yx$OnkG*cXeYL;#4F&aS z#(_Qv!CyG56d3h!{oI+qzD}mp^!0urD#?O?3W5FqDiq}Zl_>sqhy#8C|5yKSp#l~_ o{J%Q@1b__)0CV|_pkD*|e^p5q0`mXdfB>=m021`XNdN!< literal 0 HcmV?d00001 diff --git a/src/test/resources/test-input.txt.zip b/src/test/resources/test-input.txt.zip new file mode 100644 index 0000000000000000000000000000000000000000..65fb6df8ef13097eb1ccafd96a07c1451c049f70 GIT binary patch literal 347 zcmWIWW@Zs#W?ha0kT zygInkINaf_5L4~xrDysZUf-Mc@IYsy_Jd7~&)D~v7l)k?T>8T7jNl}Nr!g0D*woW4 zn|_rqJ9+1z^CfYX@)E_PTOzC2yH}U0yiVksx%|tlPA{HYXC&ubKe%+tH_ru%^GnrP zt)I@{d)ZAka?2yr!cEdQ9%Th*i!Pb|XN8Be{_nYeKF)lwXX?5Nf4?n?o;w0d-fZ3Y z{#@}v6Bgk~d5fmBEV#LeNv89ECRe;_F z0fmPDjUXE4buI=45SM|GL4twd>(Rt^og0h|PY Date: Mon, 28 Feb 2022 11:45:35 +0100 Subject: [PATCH 02/11] add temp directory and starting next version --- .github/workflows/maven.yml | 2 ++ pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 80827e0..9d34a60 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,6 +21,8 @@ jobs: with: java-version: '11' distribution: 'adopt' + run: mkdir /var/cache/oxgarage/temp + - name: maven-settings uses: s4u/maven-settings-action@v2 with: diff --git a/pom.xml b/pom.xml index 01c30c2..bf93499 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ --> uk.ac.ox.oucs.oxgarage.oo oo-converter - 1.1 + 1.1.1-SNAPSHOT OxGarage OO Converter From 0bd03e6dbf286107a7a8436b5a053f1837a0cff3 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 11:48:27 +0100 Subject: [PATCH 03/11] mkdir as its own step --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9d34a60..ceb2b83 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,7 @@ jobs: with: java-version: '11' distribution: 'adopt' - run: mkdir /var/cache/oxgarage/temp + - run: mkdir /var/cache/oxgarage/temp - name: maven-settings uses: s4u/maven-settings-action@v2 From c5eecae7774510544f76314348c4f9cfcdaed1de Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 11:50:26 +0100 Subject: [PATCH 04/11] create whole temp path --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ceb2b83..d9a8845 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,7 @@ jobs: with: java-version: '11' distribution: 'adopt' - - run: mkdir /var/cache/oxgarage/temp + - run: mkdir -p /var/cache/oxgarage/temp - name: maven-settings uses: s4u/maven-settings-action@v2 From 200c798a1dc24744108134938a1f7dd74fa3bc90 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 11:57:54 +0100 Subject: [PATCH 05/11] testing sudo --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d9a8845..6441330 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,7 @@ jobs: with: java-version: '11' distribution: 'adopt' - - run: mkdir -p /var/cache/oxgarage/temp + - run: sudo mkdir -p /var/cache/oxgarage/temp - name: maven-settings uses: s4u/maven-settings-action@v2 From ccea11afa26420bcbf7d086c658ee1058d3ae998 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 13:17:18 +0100 Subject: [PATCH 06/11] change tempDir if needed for local runs --- .github/workflows/maven.yml | 1 - .../ac/ox/oucs/oxgarage/oo/OOConverter.java | 26 ++++++++++++++----- .../ox/oucs/oxgarage/oo/OOConverterTest.java | 3 ++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6441330..9f1e726 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,6 @@ jobs: with: java-version: '11' distribution: 'adopt' - - run: sudo mkdir -p /var/cache/oxgarage/temp - name: maven-settings uses: s4u/maven-settings-action@v2 diff --git a/src/main/java/uk/ac/ox/oucs/oxgarage/oo/OOConverter.java b/src/main/java/uk/ac/ox/oucs/oxgarage/oo/OOConverter.java index 715c4d8..ebf8456 100644 --- a/src/main/java/uk/ac/ox/oucs/oxgarage/oo/OOConverter.java +++ b/src/main/java/uk/ac/ox/oucs/oxgarage/oo/OOConverter.java @@ -74,12 +74,16 @@ public class OOConverter implements Converter { converter[i] = null; } } + public void convert(InputStream inputStream, OutputStream outputStream, + final ConversionActionArguments conversionDataTypes) throws ConverterException, IOException{ + convert(inputStream, outputStream,conversionDataTypes, null); + } public void convert(InputStream inputStream, OutputStream outputStream, - final ConversionActionArguments conversionDataTypes) + final ConversionActionArguments conversionDataTypes, String tempDir) throws ConverterException, IOException { try { - transform(inputStream, outputStream, conversionDataTypes.getInputType(), conversionDataTypes.getOutputType()); + transform(inputStream, outputStream, conversionDataTypes.getInputType(), conversionDataTypes.getOutputType(), tempDir); } catch (Exception e) { e.printStackTrace(); throw new ConverterException(e.getMessage()); @@ -91,10 +95,18 @@ public List getPossibleConversions() { } private File prepareTempDir() { + return prepareTempDir(null); + } + private File prepareTempDir(String tempDir) { File inTempDir = null; String uid = UUID.randomUUID().toString(); - inTempDir = new File(EGEConstants.TEMP_PATH + File.separator + uid - + File.separator); + if(tempDir!=null){ + inTempDir = new File(tempDir + File.separator + uid + + File.separator); + } else { + inTempDir = new File(EGEConstants.TEMP_PATH + File.separator + uid + + File.separator); + } inTempDir.mkdir(); return inTempDir; } @@ -133,10 +145,10 @@ private File searchForData(File dir, String regex) { return null; } - private void transform(InputStream inputStream, OutputStream outputStream, DataType input, DataType output) + private void transform(InputStream inputStream, OutputStream outputStream, DataType input, DataType output, String tempDir) throws IOException, ConverterException { - File inTmpDir = prepareTempDir(); - File outTmpDir = prepareTempDir(); + File inTmpDir = prepareTempDir(tempDir); + File outTmpDir = prepareTempDir(tempDir); try { String inputExt = OOConfiguration.getExtension(input); File inTmpFile = prepareInputData(inputStream, inTmpDir, inputExt); diff --git a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java index b47fbb1..80f6b95 100644 --- a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java +++ b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java @@ -29,7 +29,8 @@ public void convert() throws IOException, ConverterException { DataType inputType = new DataType("txt","text/plain"); DataType outputType = new DataType("pdf","application/pdf"); ConversionActionArguments conversionActionArguments = new ConversionActionArguments(inputType, outputType, null); - converter.convert(is, os, conversionActionArguments); + 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(); From b5162e170bd694e7dfe5a62fb2cbca7d5a19bd58 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 15:04:58 +0100 Subject: [PATCH 07/11] installing libre office and setting office home --- .github/workflows/maven.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9f1e726..baa0824 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,11 @@ jobs: with: java-version: '11' distribution: 'adopt' - + - name: Install libreoffice + run: | + sudo apt-get update + sudo apt-get install libreoffice + sudo ln -s /usr/lib/libreoffice /usr/lib/openoffice - name: maven-settings uses: s4u/maven-settings-action@v2 with: From fff5c4244b2f0c3a3064eb3b7e15d7a57df69ae0 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 15:23:12 +0100 Subject: [PATCH 08/11] use temp dir in second test as well --- src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java index 80f6b95..ddc87f5 100644 --- a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java +++ b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java @@ -40,7 +40,7 @@ public void convert() throws IOException, ConverterException { 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); + converter.convert(is, os, conversionActionArguments, tempDir); assertNotNull(new File("src/test/resources/test-output.txt.zip")); is.close(); os.close(); From 9decef3503ce39a30cef2f4d39f2d6198936bd1a Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Mon, 28 Feb 2022 15:28:38 +0100 Subject: [PATCH 09/11] using new version in artifact name --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index baa0824..2ab7b14 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -37,5 +37,5 @@ jobs: - name: Upload Maven build artifact uses: actions/upload-artifact@v2 with: - name: oo-converter-1.0.jar - path: /home/runner/work/oo-converter/oo-converter/target/oo-converter-1.0.jar + name: artifact + path: /home/runner/work/oo-converter/oo-converter/target/oo-converter-1.1.1-SNAPSHOT.jar From 909b04e9916ed4aaccfc9282191b4d576d24c935 Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Tue, 1 Mar 2022 14:22:39 +0100 Subject: [PATCH 10/11] checking context of converted file --- .../uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java index ddc87f5..65d4c92 100644 --- a/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java +++ b/src/test/java/uk/ac/ox/oucs/oxgarage/oo/OOConverterTest.java @@ -1,10 +1,13 @@ 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.*; @@ -42,13 +45,18 @@ public void convert() throws IOException, ConverterException { 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()); + //System.out.println(converter.getPossibleConversions()); } } \ No newline at end of file From c5d6c7f7f55d8abae22cf0739918b4835ce762cd Mon Sep 17 00:00:00 2001 From: Anne Ferger Date: Thu, 3 Mar 2022 10:58:00 +0100 Subject: [PATCH 11/11] junit done, this is versino 1.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bf93499..82f1516 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ --> uk.ac.ox.oucs.oxgarage.oo oo-converter - 1.1.1-SNAPSHOT + 1.1.1 OxGarage OO Converter