From 72e69bece86461737d07566b2612dfae93dba159 Mon Sep 17 00:00:00 2001 From: Yannik Hampe Date: Mon, 29 May 2017 19:19:18 +0200 Subject: [PATCH] Replaced usage of deprecated methods in unit tests with current API and close exporter after use --- .../ZUGFeRD/MustangReaderWriterEdgeTest.java | 29 ++++++++----------- .../ZUGFeRD/MustangReaderWriterTest.java | 29 ++++++++----------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java index 8a12c9a0..4918d9e0 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java @@ -398,32 +398,27 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp * It would not make sense to have it run before the less complex importer test (which is probably redundant) * --> as only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export */ - public void testZExport() + public void testZExport() throws Exception { final InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505newEdge.pdf"; // the writing part - try - { + ZUGFeRDExporter ze = null; + try { // automatically add Zugferd to all outgoing invoices - ZUGFeRDExporter ze = new ZUGFeRDExporter(); - ze.PDFmakeA3compliant(SOURCE_PDF, "My Application", System.getProperty("user.name"), true); + ze = new ZUGFeRDExporterFromA1Factory() + .setProducer("My Application") + .setCreator(System.getProperty("user.name")) + .loadFromPDFA1(SOURCE_PDF); + ze.PDFattachZugferdFile(this); ze.export(TARGET_PDF); - } - catch (IOException e) - { - e.printStackTrace(); - } - catch (TransformerException e) - { - e.printStackTrace(); - } - catch (Exception e) - { - e.printStackTrace(); + } finally { + if (ze != null) { + ze.close(); + } } // now check the contents (like MustangReaderTest) diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java index 7f371f75..1da06c7d 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java @@ -398,31 +398,26 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta * It would not make sense to have it run before the less complex importer test (which is probably redundant) * --> as only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export */ - public void testZExport() + public void testZExport() throws Exception { final InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505new.pdf"; // the writing part - try - { + ZUGFeRDExporter ze = null; + try { // automatically add Zugferd to all outgoing invoices - ZUGFeRDExporter ze = new ZUGFeRDExporter(); - ze.PDFmakeA3compliant(SOURCE_PDF, "My Application", System.getProperty("user.name"), true); + ze = new ZUGFeRDExporterFromA1Factory() + .setProducer("My Application") + .setCreator(System.getProperty("user.name")) + .loadFromPDFA1(SOURCE_PDF); + ze.PDFattachZugferdFile(this); ze.export(TARGET_PDF); - } - catch (IOException e) - { - e.printStackTrace(); - } - catch (TransformerException e) - { - e.printStackTrace(); - } - catch (Exception e) - { - e.printStackTrace(); + } finally { + if (ze != null) { + ze.close(); + } } // now check the contents (like MustangReaderTest)