You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/10/19 21:15:00 UTC
[camel-quarkus] branch master updated: FOP tests fail in Quarkus
Platform #1930
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 02a182f FOP tests fail in Quarkus Platform #1930
02a182f is described below
commit 02a182fca878204756704d7f80119440f22440a2
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Mon Oct 19 15:31:11 2020 +0200
FOP tests fail in Quarkus Platform #1930
---
.../camel/quarkus/component/fop/it/FopTest.java | 35 ++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java b/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
index 25827be..e8e4b0c 100644
--- a/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
+++ b/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
@@ -20,7 +20,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.function.Function;
+import java.util.stream.Stream;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
@@ -29,6 +33,7 @@ import io.restassured.response.ExtractableResponse;
import io.restassured.specification.RequestSpecification;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -37,6 +42,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
class FopTest {
public static final String MSG = "hello";
+ private static Path tmpDir;
+
+ @BeforeAll
+ static void copyResources() throws IOException {
+ /*
+ * Local files are not available when this test is run in Quarkus Platform.
+ * ppalaga was not able to find a way to make FOP load the font declared in mycfg.xml from the classpath
+ * As a workaround, the resources are simply copied from the class loader to target/tmp directory
+ * before the test starts
+ */
+ tmpDir = Paths.get("target/tmp");
+ Files.createDirectories(tmpDir);
+ final ClassLoader cl = FopTest.class.getClassLoader();
+ Stream.of("Freedom-10eM.ttf", "mycfg.xml")
+ .forEach(resource -> {
+ final Path target = tmpDir.resolve(resource);
+ if (!Files.exists(target)) {
+ try (InputStream in = cl.getResourceAsStream(resource)) {
+ Files.copy(in, target);
+ } catch (IOException e) {
+ throw new RuntimeException("Could not read resource " + resource, e);
+ }
+ }
+ });
+ }
@Test
public void convertToPdf() throws IOException {
@@ -45,14 +75,15 @@ class FopTest {
@Test
public void convertToPdfWithCustomFont() throws IOException {
- convertToPdf(msg -> decorateTextWithXSLFO(msg, "Freedom"), "/mycfg.xml");
+ convertToPdf(msg -> decorateTextWithXSLFO(msg, "Freedom"),
+ tmpDir.resolve("mycfg.xml").toAbsolutePath().toUri().toString());
}
private void convertToPdf(Function<String, String> msgCreator, String userConfigFile) throws IOException {
RequestSpecification requestSpecification = RestAssured.given()
.contentType(ContentType.XML);
if (userConfigFile != null) {
- requestSpecification.queryParam("userConfigURL", "file:" + getClass().getResource(userConfigFile).getFile());
+ requestSpecification.queryParam("userConfigURL", userConfigFile);
}
ExtractableResponse response = requestSpecification
.body(msgCreator.apply(MSG))