Skip to content

Commit

Permalink
Add WTPDF testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Jun 13, 2024
1 parent 434ef9d commit 07a6beb
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ public boolean equals(Object obj) {
public enum Corpus {
VERA("veraPDF",
EnumSet.of(PDFAFlavour.PDFA_1_A, PDFAFlavour.PDFA_1_B, PDFAFlavour.PDFA_2_A, PDFAFlavour.PDFA_2_B,
PDFAFlavour.PDFA_2_U,
PDFAFlavour.PDFA_3_B, PDFAFlavour.PDFA_4, PDFAFlavour.PDFA_4_F, PDFAFlavour.PDFA_4_E,
PDFAFlavour.PDFUA_1, PDFAFlavour.PDFUA_2),
PDFAFlavour.PDFA_2_U, PDFAFlavour.PDFA_3_B, PDFAFlavour.PDFA_4, PDFAFlavour.PDFA_4_F,
PDFAFlavour.PDFA_4_E, PDFAFlavour.PDFUA_1, PDFAFlavour.PDFUA_2,
PDFAFlavour.WTPDF_1_0_REUSE, PDFAFlavour.WTPDF_1_0_ACCESSIBILITY),
URI.create(VERA_URL), "veraCorp-"),
ISARTOR("Isartor", EnumSet.of(PDFAFlavour.PDFA_1_B), URI.create(ISARTOR_URL), "isartCorp-"),
BFO("BFO", EnumSet.of(PDFAFlavour.PDFA_2_B), URI.create(BFO_URL), "bfoCorp-"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.verapdf.pdfa.qa;

import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.flavours.PDFFlavours;
import org.verapdf.pdfa.validation.profiles.ProfileDirectory;
import org.verapdf.pdfa.validation.profiles.Profiles;
import org.verapdf.pdfa.validation.profiles.ValidationProfile;
Expand Down Expand Up @@ -111,15 +112,12 @@ public static ProfileDirectory fromBranch(final String branchName) {
return new GitHubBackedProfileDirectory(branchName);
}
private static Set<ValidationProfile> fromGitHubBranch(final String branchName) {
String PDFApathPrefix = GITHUB_ROOT + branchName + PDFA_PROFILE_PATH_PART + PDFA_PROFILE_PREFIX;
String PDFUApathPrefix = GITHUB_ROOT + branchName + PDFUA_PROFILE_PATH_PART + PDFUA_PROFILE_PREFIX;
Set<ValidationProfile> profileSet = new HashSet<>();
for (PDFAFlavour flavour : PDFAFlavour.values()) {
if (flavour == PDFAFlavour.NO_FLAVOUR || flavour.getPart().getFamily() == PDFAFlavour.SpecificationFamily.WCAG) {
continue;
}
String profileURLString = (flavour.getPart().getFamily() != PDFAFlavour.SpecificationFamily.PDF_UA ? PDFApathPrefix : PDFUApathPrefix)
+ flavour.getPart().getPartNumber() + flavour.getLevel().getCode().toUpperCase() + XML_SUFFIX;
String profileURLString = getProfilePath(flavour, branchName);
try {
URL profileURL = new URL(profileURLString);
ValidationProfile profile = Profiles.profileFromXml(profileURL.openStream());
Expand All @@ -137,4 +135,30 @@ private static Set<ValidationProfile> fromGitHubBranch(final String branchName)
}
return profileSet;
}

private static String getProfilePath(PDFAFlavour flavour, String branchName) {
StringBuilder profilePath = new StringBuilder();
profilePath.append(GITHUB_ROOT);
profilePath.append(branchName);
if ((PDFFlavours.isWTPDFFlavour(flavour) || PDFFlavours.isPDFUARelatedFlavour(flavour))) {
profilePath.append(PDFUA_PROFILE_PATH_PART);
} else {
profilePath.append(PDFA_PROFILE_PATH_PART);
}
profilePath.append(flavour.getPart().getFamily().getFamily().replace("/", "")); //$NON-NLS-1$
profilePath.append("-"); //$NON-NLS-1$
profilePath.append(flavour.getPart().getPartNumber());
if (flavour.getPart().getSubpartNumber() != null) {
profilePath.append("-"); //$NON-NLS-1$
profilePath.append(flavour.getPart().getSubpartNumber());
}
if (PDFFlavours.isWTPDFFlavour(flavour)) {
profilePath.append("-"); //$NON-NLS-1$
profilePath.append(flavour.getLevel().getCode());
} else {
profilePath.append(flavour.getLevel().getCode().toUpperCase()); //$NON-NLS-1$
}
profilePath.append(XML_SUFFIX);
return profilePath.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.verapdf.pdfa.PDFAParser;
import org.verapdf.pdfa.PDFAValidator;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.flavours.PDFFlavours;
import org.verapdf.pdfa.results.ValidationResult;
import org.verapdf.pdfa.validation.profiles.Profiles;
import org.verapdf.pdfa.validation.profiles.ValidationProfile;
Expand All @@ -31,10 +32,7 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.lang.management.ManagementFactory;
import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -199,6 +197,10 @@ public String toString() {
* @return
*/
public static ResultSet validateCorpus(final TestCorpus corpus, final PDFAValidator validator, final PDFAFlavour flavour) {
if (Foundries.defaultParserIsPDFBox() && PDFFlavours.isWTPDFFlavour(flavour)) {
return new ResultSetImpl(corpus.getDetails(), corpus.getType().getId(), validator.getProfile(),
Collections.emptySet(), Collections.emptySet(), null, 0);
}
Set<Result> results = new HashSet<>();
Set<Incomplete> exceptions = new HashSet<>();
Components.Timer batchTimer = Components.Timer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.apache.commons.codec.digest.DigestUtils;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.flavours.PDFFlavours;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -118,6 +119,9 @@ public static boolean checkFlavour(final String item, final PDFAFlavour flavour)
if (flavour == PDFAFlavour.PDFUA_1) {
return item.contains("PDF_UA-1");
}
if (PDFFlavours.isWTPDFFlavour(flavour)) {
return item.contains("PDF_UA-2");
}
if (flavour == PDFAFlavour.PDFUA_2) {
return item.contains("PDF_UA-2");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
"ua2":
[
]
"wt1r":
[
"5-t2-pass-a",
"8.2.5.28.2-t1-fail-a",
"8.7-t2-fail-a",
"8.11.2-t1-fail-a",
"8.11.2-t1-fail-b"
]
"wt1a":
[
"5-t2-pass-a"
]
"BFO":
"2b":
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@
"8.11.1-t1-pass-a",
"8.11.2-t1-pass-a"
]
"wt1r":
[
]
"wt1a":
[
]
"BFO":
"2b":
[
Expand Down

0 comments on commit 07a6beb

Please sign in to comment.