This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch camel-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit e937549b70ccf2eb595a3962ec225e4b2dbd2e45 Author: JiriOndrusek <ondrusek.j...@gmail.com> AuthorDate: Tue Aug 29 13:30:07 2023 +0200 Fixed compilatin errors in Pdf and Fop because of CAMEL-19796 --- .../org/apache/camel/quarkus/component/fop/it/FopTest.java | 4 +++- .../org/apache/camel/quarkus/component/pdf/it/PdfResource.java | 10 +++++----- .../org/apache/camel/quarkus/component/pdf/it/PdfTest.java | 7 ++++--- 3 files changed, 12 insertions(+), 9 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 e8e4b0ccad..c2da410823 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 @@ -31,6 +31,8 @@ import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.response.ExtractableResponse; import io.restassured.specification.RequestSpecification; +import org.apache.pdfbox.Loader; +import org.apache.pdfbox.io.RandomAccessReadBuffer; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.text.PDFTextStripper; import org.junit.jupiter.api.BeforeAll; @@ -117,7 +119,7 @@ class FopTest { } private PDDocument getDocumentFrom(InputStream inputStream) throws IOException { - return PDDocument.load(inputStream); + return Loader.loadPDF(new RandomAccessReadBuffer(inputStream)); } private String extractTextFrom(PDDocument document) throws IOException { diff --git a/integration-tests/pdf/src/main/java/org/apache/camel/quarkus/component/pdf/it/PdfResource.java b/integration-tests/pdf/src/main/java/org/apache/camel/quarkus/component/pdf/it/PdfResource.java index aafbbeec76..d5630e51e8 100644 --- a/integration-tests/pdf/src/main/java/org/apache/camel/quarkus/component/pdf/it/PdfResource.java +++ b/integration-tests/pdf/src/main/java/org/apache/camel/quarkus/component/pdf/it/PdfResource.java @@ -16,7 +16,6 @@ */ package org.apache.camel.quarkus.component.pdf.it; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.URI; @@ -33,6 +32,7 @@ import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import org.apache.camel.ProducerTemplate; import org.apache.camel.component.pdf.PdfHeaderConstants; +import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.encryption.AccessPermission; import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial; @@ -56,7 +56,7 @@ public class PdfResource { @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response createFromText(String message) throws Exception { document = producerTemplate.requestBody( - "pdf:create?fontSize=6&pageSize=PAGE_SIZE_A5&font=Courier", message, byte[].class); + "pdf:create?fontSize=6&pageSize=PAGE_SIZE_A5&font=COURIER", message, byte[].class); LOG.infof("The PDDocument has been created and contains %d bytes", document.length); @@ -69,7 +69,7 @@ public class PdfResource { @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response appendText(String message) throws Exception { document = producerTemplate.requestBodyAndHeader("pdf:append", message, - PdfHeaderConstants.PDF_DOCUMENT_HEADER_NAME, PDDocument.load(document), byte[].class); + PdfHeaderConstants.PDF_DOCUMENT_HEADER_NAME, Loader.loadPDF(document), byte[].class); LOG.infof("The PDDocument has been updated and now contains %d bytes", document.length); @@ -81,7 +81,7 @@ public class PdfResource { @Produces(MediaType.TEXT_PLAIN) public String get() throws Exception { LOG.info("Extracting text from the PDDocument"); - return producerTemplate.requestBody("pdf:extractText", PDDocument.load(document), String.class); + return producerTemplate.requestBody("pdf:extractText", Loader.loadPDF(document), String.class); } @Path("/encrypt/standard") @@ -111,7 +111,7 @@ public class PdfResource { public Response decryptStandard(@QueryParam("password") String password, byte[] rawDocument) throws IOException { StandardDecryptionMaterial material = new StandardDecryptionMaterial(password); - PDDocument document = PDDocument.load(new ByteArrayInputStream(rawDocument), password); + PDDocument document = Loader.loadPDF(rawDocument, password); String result = producerTemplate.requestBodyAndHeader( "pdf:extractText", diff --git a/integration-tests/pdf/src/test/java/org/apache/camel/quarkus/component/pdf/it/PdfTest.java b/integration-tests/pdf/src/test/java/org/apache/camel/quarkus/component/pdf/it/PdfTest.java index a5a7e25149..c50fa39381 100644 --- a/integration-tests/pdf/src/test/java/org/apache/camel/quarkus/component/pdf/it/PdfTest.java +++ b/integration-tests/pdf/src/test/java/org/apache/camel/quarkus/component/pdf/it/PdfTest.java @@ -21,6 +21,7 @@ import java.io.IOException; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.http.ContentType; +import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; import org.apache.pdfbox.text.PDFTextStripper; @@ -42,7 +43,7 @@ class PdfTest { .body("content to be included in the created pdf document").post("/pdf/createFromText").then().statusCode(201) .extract().asByteArray(); - PDDocument doc = PDDocument.load(bytes); + PDDocument doc = Loader.loadPDF(bytes); PDFTextStripper pdfTextStripper = new PDFTextStripper(); String text = pdfTextStripper.getText(doc); assertEquals(1, doc.getNumberOfPages()); @@ -56,7 +57,7 @@ class PdfTest { byte[] bytes = RestAssured.given().contentType(ContentType.TEXT).body("another line that should be appended") .put("/pdf/appendText").then().statusCode(200).extract().asByteArray(); - PDDocument doc = PDDocument.load(bytes); + PDDocument doc = Loader.loadPDF(bytes); PDFTextStripper pdfTextStripper = new PDFTextStripper(); String text = pdfTextStripper.getText(doc); assertEquals(2, doc.getNumberOfPages()); @@ -92,7 +93,7 @@ class PdfTest { .asByteArray(); // Test loading the PDF without credentials - Assertions.assertThrows(InvalidPasswordException.class, () -> PDDocument.load(bytes)); + Assertions.assertThrows(InvalidPasswordException.class, () -> Loader.loadPDF(bytes)); // Decrypt RestAssured.given()