reactivated a test

This commit is contained in:
Jochen Stärk
2019-04-21 18:09:15 +02:00
parent 9a3a32a91c
commit 015a530222
3 changed files with 17 additions and 12 deletions

View File

@@ -52,11 +52,13 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
public final String prefix_pdfaProperty = "pdfaProperty"; public final String prefix_pdfaProperty = "pdfaProperty";
public String namespace = null; public String namespace = null;
public String prefix = null; public String prefix = null;
protected ZUGFeRDExporter exporter;
protected void setZUGFeRDVersion(int ver) { protected void setZUGFeRDVersion(int ver) {
namespace = ZUGFeRDExporter.getNamespaceForVersion(ver); namespace = exporter.getNamespaceForVersion(ver);
prefix = ZUGFeRDExporter.getPrefixForVersion(ver); prefix = exporter.getPrefixForVersion(ver);
} }
@@ -87,14 +89,16 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
return li; return li;
} }
public XMPSchemaPDFAExtensions(XMPMetadata metadata, int ZFVersion) { public XMPSchemaPDFAExtensions(ZUGFeRDExporter ze, XMPMetadata metadata, int ZFVersion) {
super(metadata); super(metadata);
exporter=ze;
setZUGFeRDVersion(ZFVersion); setZUGFeRDVersion(ZFVersion);
attachExtensions(metadata, true); attachExtensions(metadata, true);
} }
public XMPSchemaPDFAExtensions(XMPMetadata metadata, int ZFVersion, boolean withZF) { public XMPSchemaPDFAExtensions(ZUGFeRDExporter ze, XMPMetadata metadata, int ZFVersion, boolean withZF) {
super(metadata); super(metadata);
exporter=ze;
setZUGFeRDVersion(ZFVersion); setZUGFeRDVersion(ZFVersion);
attachExtensions(metadata, withZF); attachExtensions(metadata, withZF);
} }

View File

@@ -55,7 +55,7 @@ public class ZUGFeRDExporter implements Closeable {
public static final int DefaultZUGFeRDVersion = 1; public static final int DefaultZUGFeRDVersion = 1;
private static boolean isFacturX = false; private boolean isFacturX = false;
/** /**
* To use the ZUGFeRD exporter, implement IZUGFeRDExportableTransaction in * To use the ZUGFeRD exporter, implement IZUGFeRDExportableTransaction in
@@ -133,7 +133,7 @@ public class ZUGFeRDExporter implements Closeable {
additionalXMLs.put(filename, xml); additionalXMLs.put(filename, xml);
} }
public static String getNamespaceForVersion(int ver) { public String getNamespaceForVersion(int ver) {
if (isFacturX) { if (isFacturX) {
return "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#"; return "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#";
} else if (ver == 1) { } else if (ver == 1) {
@@ -146,7 +146,7 @@ public class ZUGFeRDExporter implements Closeable {
} }
} }
public static String getPrefixForVersion(int ver) { public String getPrefixForVersion(int ver) {
if (isFacturX) { if (isFacturX) {
return "fx"; return "fx";
} else { } else {
@@ -154,7 +154,7 @@ public class ZUGFeRDExporter implements Closeable {
} }
} }
public static String getFilenameForVersion(int ver) { public String getFilenameForVersion(int ver) {
if (isFacturX) { if (isFacturX) {
return "factur-x.xml"; return "factur-x.xml";
} else { } else {
@@ -498,13 +498,13 @@ public class ZUGFeRDExporter implements Closeable {
if (attachZUGFeRDHeaders) { if (attachZUGFeRDHeaders) {
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, profile, XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, profile,
ZUGFeRDExporter.getNamespaceForVersion(ZFVersion), ZUGFeRDExporter.getPrefixForVersion(ZFVersion), getNamespaceForVersion(ZFVersion), getPrefixForVersion(ZFVersion),
ZUGFeRDExporter.getFilenameForVersion(ZFVersion)); getFilenameForVersion(ZFVersion));
metadata.addSchema(zf); metadata.addSchema(zf);
} }
XMPSchemaPDFAExtensions pdfaex = new XMPSchemaPDFAExtensions(metadata, ZFVersion, attachZUGFeRDHeaders); XMPSchemaPDFAExtensions pdfaex = new XMPSchemaPDFAExtensions(this, metadata, ZFVersion, attachZUGFeRDHeaders);
pdfaex.setZUGFeRDVersion(ZFVersion); pdfaex.setZUGFeRDVersion(ZFVersion);
metadata.addSchema(pdfaex); metadata.addSchema(pdfaex);

View File

@@ -506,6 +506,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
assertEquals(zi.getForeignReference(), getNumber()); assertEquals(zi.getForeignReference(), getNumber());
} }
public void testFXExport() throws Exception { public void testFXExport() throws Exception {
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20171118_506fx.pdf"; final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20171118_506fx.pdf";
@@ -514,7 +515,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
try (InputStream SOURCE_PDF = this.getClass() try (InputStream SOURCE_PDF = this.getClass()
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf"); .getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().setZUGFeRDVersion(2).setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931).load(SOURCE_PDF)) { ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().setZUGFeRDVersion(2).setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931).load(SOURCE_PDF)) {
ze.setFacturX(); ze.setFacturX();
ze.PDFattachZugferdFile(this); ze.PDFattachZugferdFile(this);
ze.disableAutoClose(true); ze.disableAutoClose(true);