added a unit test. corrected main
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
- support pdf export/visualization to PDF, thanks to Heavenfighter #387 allow embedd fonts from jar-file for pdf creation #388
|
- support pdf export/visualization to PDF, thanks to Heavenfighter #387 allow embedd fonts from jar-file for pdf creation #388
|
||||||
- Fix #389: ClassCastException: ZUGFeRDExporterFromA3
|
- Fix #389: ClassCastException: ZUGFeRDExporterFromA3
|
||||||
|
- jakarta support #372
|
||||||
|
- Upgrade to PDFBox 3 #373
|
||||||
2.11.0
|
2.11.0
|
||||||
=======
|
=======
|
||||||
2024-05-22
|
2024-05-22
|
||||||
|
|||||||
@@ -331,31 +331,34 @@ public class Main {
|
|||||||
try {
|
try {
|
||||||
CommandLine cmd;
|
CommandLine cmd;
|
||||||
CommandLineParser parser = new BasicParser();
|
CommandLineParser parser = new BasicParser();
|
||||||
|
|
||||||
// create Options object
|
// create Options object
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption(new Option("h", "help", false, "display usage"));
|
options.addOption(new Option("h", "help", false, "display usage"));
|
||||||
options.addOption(new Option("a", "action", true, "which action to perform"));
|
options.addOption(new Option("a", "action", true, "which action to perform"));
|
||||||
options.addOption(new Option("f", "format", true, "which format to output"));
|
options.addOption(new Option("f", "format", true, "which format to output"));
|
||||||
options.addOption(new Option("", "version", true, "which version of the standard to use"));
|
options.addOption(new Option("version", "version", true, "which version of the standard to use"));
|
||||||
options.addOption(new Option("", "profile", true, "which profile of the standard to use"));
|
options.addOption(new Option("profile", "profile", true, "which profile of the standard to use"));
|
||||||
Option attachmentOpt = new Option("", "attachments", true, "File attachments");
|
Option attachmentOpt = new Option("attachments", "attachments", true, "File attachments");
|
||||||
attachmentOpt.setValueSeparator(',');
|
attachmentOpt.setValueSeparator(',');
|
||||||
attachmentOpt.setArgs(Option.UNLIMITED_VALUES);
|
attachmentOpt.setArgs(Option.UNLIMITED_VALUES);
|
||||||
|
|
||||||
options.addOption(attachmentOpt);
|
options.addOption(attachmentOpt);
|
||||||
options.addOption(new Option("", "source",true, "which source file to use"));
|
options.addOption(new Option("source", "source",true, "which source file to use"));
|
||||||
options.addOption(new Option("", "source-xml",true, "which source file to use"));
|
options.addOption(new Option("source-xml", "source-xml",true, "which source file to use"));
|
||||||
options.addOption(new Option("", "language",true, "output language (en, de or fr)"));
|
options.addOption(new Option("language", "language",true, "output language (en, de or fr)"));
|
||||||
options.addOption(new Option("", "out",true, "which output file to write to"));
|
options.addOption(new Option("out", "out",true, "which output file to write to"));
|
||||||
options.addOption(new Option("", "no-notices",false, "suppress non-fatal errors"));
|
options.addOption(new Option("no-notices", "no-notices",false, "suppress non-fatal errors"));
|
||||||
options.addOption(new Option("", "logAppend",true, "freeform text to be appended to log messages"));
|
options.addOption(new Option("logAppend", "logAppend",true, "freeform text to be appended to log messages"));
|
||||||
options.addOption(new Option("", "disable-file-logging", false, "suppress logging to file"));
|
options.addOption(new Option("disable-file-logging", "disable-file-logging", false, "suppress logging to file"));
|
||||||
options.addOption(new Option("d", "directory",true, "which directory to operate on"));
|
options.addOption(new Option("d", "directory",true, "which directory to operate on"));
|
||||||
options.addOption(new Option("i", "ignorefileextension",false, "ignore non-matching file extensions"));
|
options.addOption(new Option("i", "ignorefileextension",false, "ignore non-matching file extensions"));
|
||||||
options.addOption(new Option("l", "listfromstdin",false, "take list of files from commandline"));
|
options.addOption(new Option("l", "listfromstdin",false, "take list of files from commandline"));
|
||||||
|
|
||||||
boolean optionsRecognized=false;
|
boolean optionsRecognized=false;
|
||||||
String action = "";
|
String action = "";
|
||||||
Boolean disableFileLogging = false;
|
|
||||||
|
Boolean disableFileLogging = false;
|
||||||
try {
|
try {
|
||||||
cmd = parser.parse(options, args);
|
cmd = parser.parse(options, args);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* *********************************************************************
|
||||||
|
* <p>
|
||||||
|
* Copyright 2019 Jochen Staerk
|
||||||
|
* <p>
|
||||||
|
* Use is subject to license terms.
|
||||||
|
* <p>
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
* <p>
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* <p>
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* <p>
|
||||||
|
* **********************************************************************
|
||||||
|
*/
|
||||||
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.junit.FixMethodOrder;
|
||||||
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.mustangproject.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
public class PreValidationTest extends TestCase {
|
||||||
|
final String TARGET_PDF = "./target/testout-Preval.pdf";
|
||||||
|
final String SOURCE_PDF = "/veraPDFtestsuite6-7-11-t01-fail-a.pdf";
|
||||||
|
|
||||||
|
public void testFailIgnore() {
|
||||||
|
|
||||||
|
// the writing part
|
||||||
|
|
||||||
|
|
||||||
|
boolean hasEx = false;
|
||||||
|
try (InputStream source = this.getClass()
|
||||||
|
.getResourceAsStream(SOURCE_PDF)) {
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2)
|
||||||
|
.load(source);
|
||||||
|
ze.setTransaction(createInvoice());
|
||||||
|
|
||||||
|
ze.export(TARGET_PDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
hasEx = true;
|
||||||
|
}
|
||||||
|
assertTrue(hasEx);
|
||||||
|
hasEx = false;
|
||||||
|
try (InputStream source = this.getClass()
|
||||||
|
.getResourceAsStream(SOURCE_PDF)) {
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application").ignorePDFAErrors()
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2)
|
||||||
|
.load(source);
|
||||||
|
ze.setTransaction(createInvoice());
|
||||||
|
ze.export(TARGET_PDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
hasEx = true;
|
||||||
|
}
|
||||||
|
assertFalse(hasEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Invoice createInvoice() {
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String amountStr = "1.00";
|
||||||
|
BigDecimal amount = new BigDecimal(amountStr);
|
||||||
|
return new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
|
||||||
|
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID("DE4711").addVATID("DE0815").setEmail("info@example.org").setContact(new Contact("Hans Test", "+49123456789", "test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890", "COBADEFXXX")))
|
||||||
|
.setRecipient(new TradeParty("Theodor Est", "Bahnstr. 42", "88802", "Spielkreis", "DE"))
|
||||||
|
.setReferenceNumber("991-01484-64")//leitweg-id
|
||||||
|
// not using any VAT, this is also a test of zero-rated goods:
|
||||||
|
.setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", BigDecimal.ZERO), amount, new BigDecimal(1.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
library/src/test/resources/veraPDFtestsuite6-7-11-t01-fail-a.pdf
Normal file
BIN
library/src/test/resources/veraPDFtestsuite6-7-11-t01-fail-a.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user