Skip to content

Commit

Permalink
Merge pull request #27 from vpa1977/pdfbox-test
Browse files Browse the repository at this point in the history
Add Apache PDFBox self-test (graphics/fonts/crypto)
  • Loading branch information
vpa1977 authored Feb 17, 2023
2 parents 30e7953 + e5e7da3 commit d088b70
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
- name: Tests Maven cache
uses: actions/cache@v3
with:
path: tests/petclinic-test/.m2
path: |
tests/petclinic-test/.m2
tests/pdfbox/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.m2
*.zip
*.tar.gz
pdfbox-2.0.27
?
sh
32 changes: 32 additions & 0 deletions tests/pdfbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG BASE_IMAGE=ubuntu/chiselled-jre:8_edge
ARG MAVEN_IMAGE=maven:3.9.0-eclipse-temurin-8
ARG USER=app
ARG UID=101
ARG GROUP=app
ARG GID=101

FROM $MAVEN_IMAGE as builder

FROM $BASE_IMAGE

ARG USER
ARG UID
ARG GID
USER $UID:$GID
COPY --from=builder /bin/sh /bin/sh
COPY --from=builder /usr/bin/chmod /usr/bin/chmod
COPY --from=builder /usr/bin/uname /usr/bin/uname
COPY --from=builder /usr/bin/dirname /usr/bin/dirname
# note, Temurin base does not install into /etc/maven and /usr/share/java
# other base might require copying those folders
COPY --from=builder /usr/share/maven /usr/share/maven

ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

# Add javac compiler for maven (it always recompiles package-info.java)
COPY --from=builder /opt/java/openjdk/bin/javac \
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/
COPY --from=builder /opt/java/openjdk/lib/tools.jar \
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/

ENTRYPOINT [ "/usr/share/maven/bin/mvn" ]
13 changes: 13 additions & 0 deletions tests/pdfbox/TestCreateSignature.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java b/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
index 652e6f0..26c5103 100644
--- a/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
+++ b/examples/src/test/java/org/apache/pdfbox/examples/pdmodel/TestCreateSignature.java
@@ -970,6 +970,8 @@ public class TestCreateSignature

// Check that the issueing certificate is in the VRI array
COSDictionary crlSigDict = vriDict.getCOSDictionary(COSName.getPDFName(hexCrlSignatureHash));
+ // patch out occasional https://issues.apache.org/jira/browse/PDFBOX-5203
+ if (crlSigDict == null) continue;
COSArray certArray2 = crlSigDict.getCOSArray(COSName.getPDFName("Cert"));
COSStream certStream = (COSStream) certArray2.getObject(0);
InputStream is2 = certStream.createInputStream();
30 changes: 30 additions & 0 deletions tests/pdfbox/runtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

set -ex

VERSION=2.0.27
APP=pdfbox-${VERSION}
MAVEN_IMAGE=maven:3.9.0-eclipse-temurin-8
TEST_DIR=`pwd`

if [ ! -d ${APP} ]; then
curl -o ${APP}-src.zip https://dlcdn.apache.org/pdfbox/${VERSION}/${APP}-src.zip
(unzip -o ${APP}-src.zip && cd ${APP} && git apply ../TestCreateSignature.patch)
fi

# create the chiselled JRE docker with maven
docker build -t chiselled-maven \
--build-arg MAVEN_IMAGE=${MAVEN_IMAGE} \
--build-arg BASE_IMAGE=${BASE_IMAGE:-ubuntu/chiselled-jre:8_edge} \
.

# build and tests with chiselled jre
docker run --rm \
--tmpfs /tmp:exec \
-u $(id -u ${USER}):$(id -g ${USER}) \
-v ${TEST_DIR}:${TEST_DIR} \
-w ${TEST_DIR}/${APP} \
chiselled-maven \
-Dmaven.repo.local="${TEST_DIR}/.m2" \
-Dmaven.compiler.useIncrementalCompilation=false \
test

0 comments on commit d088b70

Please sign in to comment.