closes #527
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package org.mustangproject.commandline;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -10,18 +8,43 @@ import java.nio.file.Paths;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CliIT {
|
||||
|
||||
public static File getResourceAsFile(String resourcePath) {
|
||||
try {
|
||||
InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream(resourcePath);
|
||||
if (in == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File tempFile = File.createTempFile(String.valueOf(in.hashCode()), ".tmp");
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
||||
// copy stream
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
return tempFile;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCii2Ubl() throws Exception {
|
||||
Path output = Paths.get("target/ubl.xml");
|
||||
Files.deleteIfExists(output);
|
||||
Path jar = Files.newDirectoryStream(Paths.get("target"), "Mustang-CLI-*.jar").iterator().next();
|
||||
ProcessBuilder pb = new ProcessBuilder("java", "-jar", jar.toString(),
|
||||
"--action", "ubl", "--source", "src/test/resources/cii.xml", "--out",
|
||||
output.toString());
|
||||
"--action", "ubl", "--source", "src/test/resources/cii.xml", "--out",
|
||||
output.toString());
|
||||
pb.redirectErrorStream(true);
|
||||
Process process = pb.start();
|
||||
String result = getOutput(process);
|
||||
@@ -43,4 +66,17 @@ public class CliIT {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetric() {
|
||||
StatRun sr = new StatRun();
|
||||
File tempFile = getResourceAsFile("corrupt-factur-x-waytoosmall.pdf");
|
||||
|
||||
FileChecker fc = new FileChecker(tempFile.getAbsolutePath(), sr);
|
||||
|
||||
fc.checkForZUGFeRD();
|
||||
System.out.print(fc.getOutputLine());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
%PDF-1.4
|
||||
%ェォャュ
|
||||
Reference in New Issue
Block a user