From 1ec64c61103a637494eb602174c255d5187bafe4 Mon Sep 17 00:00:00 2001 From: Ulrich Zielhofer Date: Fri, 17 Dec 2021 08:48:04 +0100 Subject: [PATCH] solves #227: create both non-shaded and shaded jar for library, while not breaking CLI --- .gitignore | 3 +- Mustang-CLI/pom.xml | 13 ++ .../org/mustangproject/commandline/CliIT.java | 47 +++++ Mustang-CLI/src/test/resources/cii.xml | 191 ++++++++++++++++++ library/pom.xml | 3 +- validator/pom.xml | 6 + 6 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 Mustang-CLI/src/test/java/org/mustangproject/commandline/CliIT.java create mode 100644 Mustang-CLI/src/test/resources/cii.xml diff --git a/.gitignore b/.gitignore index ece11c66..2702c983 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ target/ pom.xml.* bin/ /.gradle/ +log/ # ignore intelliJ foobar *.iml @@ -14,4 +15,4 @@ bin/ # ignore test files ZUGFeRD-*-test -dependency-reduced-pom.xml \ No newline at end of file +dependency-reduced-pom.xml diff --git a/Mustang-CLI/pom.xml b/Mustang-CLI/pom.xml index 41357a94..3cb92a76 100644 --- a/Mustang-CLI/pom.xml +++ b/Mustang-CLI/pom.xml @@ -181,6 +181,19 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + + + integration-test + verify + + + + diff --git a/Mustang-CLI/src/test/java/org/mustangproject/commandline/CliIT.java b/Mustang-CLI/src/test/java/org/mustangproject/commandline/CliIT.java new file mode 100644 index 00000000..43a1a2d1 --- /dev/null +++ b/Mustang-CLI/src/test/java/org/mustangproject/commandline/CliIT.java @@ -0,0 +1,47 @@ +package org.mustangproject.commandline; + +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertTrue; + +public class CliIT { + + @Test + public void testCii2Ubl() throws Exception { + Path output = Paths.get("target/ubl.xml"); + Files.deleteIfExists(output); + Path jar = Files.newDirectoryStream(Paths.get("target"), "Mustang-CLI-*.jar").iterator().next(); + ProcessBuilder pb = new ProcessBuilder("java", "-jar", jar.toString(), + "--action", "ubl", "--source", "src/test/resources/cii.xml", "--out", + output.toString()); + pb.redirectErrorStream(true); + Process process = pb.start(); + String result = getOutput(process); + process.waitFor(10, TimeUnit.SECONDS); + if (!result.isEmpty()) { + System.out.println(result); + } + assertTrue(new String(Files.readAllBytes(output), StandardCharsets.UTF_8).contains("Invoice")); + } + + private String getOutput(Process process) throws IOException { + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + StringBuilder builder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line); + builder.append(System.getProperty("line.separator")); + } + return builder.toString(); + } + +} diff --git a/Mustang-CLI/src/test/resources/cii.xml b/Mustang-CLI/src/test/resources/cii.xml new file mode 100644 index 00000000..44ce2bd5 --- /dev/null +++ b/Mustang-CLI/src/test/resources/cii.xml @@ -0,0 +1,191 @@ + + + + + + urn:cen.eu:en16931:2017 + + + + RE-20201121/508 + 380 + + 20201121 + + + + + + 1 + + + Design (hours) + Of a sample invoice + + + + 160.0000 + 1.0000 + + + 160.0000 + 1.0000 + + + + 1.0000 + + + + VAT + S + 7.00 + + + 160.00 + + + + + + 2 + + + Ballons + various colors, ~2000ml + + + + 0.7900 + 1.0000 + + + 0.7900 + 1.0000 + + + + 400.0000 + + + + VAT + S + 19.00 + + + 316.00 + + + + + + 3 + + + Hot air „heiße Luft“ (litres) + + + + + 0.0250 + 1.0000 + + + 0.0250 + 1.0000 + + + + 800.0000 + + + + VAT + S + 19.00 + + + 20.00 + + + + + AB321 + + Bei Spiel GmbH + + 12345 + Ecke 12 + Stadthausen + DE + + + DE136695976 + + + + 2 + Theodor Est + + 88802 + Bahnstr. 42 + Spielkreis + DE + + + + + + + 20201110 + + + + + RE-20201121/508 + EUR + + 42 + Bank transfer + + DE88200800000970375700 + Max Mustermann + + + COBADEFFXXX + + + + 11.20 + VAT + 160.00 + S + 7.00 + + + 63.84 + VAT + 336.00 + S + 19.00 + + + Zahlbar ohne Abzug bis 12.12.2020 + + 20201212 + + + + 496.00 + 0.00 + 0.00 + 496.00 + 75.04 + 571.04 + 0.00 + 571.04 + + + + diff --git a/library/pom.xml b/library/pom.xml index 5d7be630..6e5103a5 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -122,6 +122,7 @@ org.xmlunit xmlunit-assertj 2.6.3 + test @@ -153,7 +154,7 @@ maven-shade-plugin 3.2.1 - false + true false diff --git a/validator/pom.xml b/validator/pom.xml index affdd31c..aa3b9ad0 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -74,6 +74,11 @@ ph-schematron 5.6.0 + + com.helger + ph-jaxb + 9.5.4 + org.mustangproject library @@ -83,6 +88,7 @@ org.xmlunit xmlunit-core 2.6.3 + test org.xmlunit