Replaced usage of deprecated methods in unit tests with current API and close exporter after use
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user