Replaced usage of deprecated methods in unit tests with current API and close exporter after use

This commit is contained in:
Yannik Hampe
2017-05-29 19:19:18 +02:00
parent e6db5791c4
commit 72e69bece8
2 changed files with 24 additions and 34 deletions

View File

@@ -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) * 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 * --> 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 InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505newEdge.pdf"; final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505newEdge.pdf";
// the writing part // the writing part
try ZUGFeRDExporter ze = null;
{ try {
// automatically add Zugferd to all outgoing invoices // automatically add Zugferd to all outgoing invoices
ZUGFeRDExporter ze = new ZUGFeRDExporter(); ze = new ZUGFeRDExporterFromA1Factory()
ze.PDFmakeA3compliant(SOURCE_PDF, "My Application", System.getProperty("user.name"), true); .setProducer("My Application")
.setCreator(System.getProperty("user.name"))
.loadFromPDFA1(SOURCE_PDF);
ze.PDFattachZugferdFile(this); ze.PDFattachZugferdFile(this);
ze.export(TARGET_PDF); ze.export(TARGET_PDF);
} } finally {
catch (IOException e) if (ze != null) {
{ ze.close();
e.printStackTrace(); }
}
catch (TransformerException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
} }
// now check the contents (like MustangReaderTest) // now check the contents (like MustangReaderTest)

View File

@@ -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) * 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 * --> 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 InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505new.pdf"; final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505new.pdf";
// the writing part // the writing part
try ZUGFeRDExporter ze = null;
{ try {
// automatically add Zugferd to all outgoing invoices // automatically add Zugferd to all outgoing invoices
ZUGFeRDExporter ze = new ZUGFeRDExporter(); ze = new ZUGFeRDExporterFromA1Factory()
ze.PDFmakeA3compliant(SOURCE_PDF, "My Application", System.getProperty("user.name"), true); .setProducer("My Application")
.setCreator(System.getProperty("user.name"))
.loadFromPDFA1(SOURCE_PDF);
ze.PDFattachZugferdFile(this); ze.PDFattachZugferdFile(this);
ze.export(TARGET_PDF); ze.export(TARGET_PDF);
} } finally {
catch (IOException e) if (ze != null) {
{ ze.close();
e.printStackTrace(); }
}
catch (TransformerException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
} }
// now check the contents (like MustangReaderTest) // now check the contents (like MustangReaderTest)