Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<properties>
<jacoco.version>0.8.1</jacoco.version>
<verapdf.greenfield.version>[1.29.0,1.30.0-RC)</verapdf.greenfield.version>
<verapdf.pdfbox.version>[1.27.0,1.28.0-RC)</verapdf.pdfbox.version>
<verapdf.library.version>[1.29.0,1.30.0-RC)</verapdf.library.version>
<org.bouncycastle.version>1.70</org.bouncycastle.version>
</properties>
Expand All @@ -86,12 +85,6 @@
<version>${verapdf.library.version}</version>
</dependency>

<dependency>
<groupId>org.verapdf</groupId>
<artifactId>pdfbox-validation-model</artifactId>
<version>${verapdf.pdfbox.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ private static Set<ValidationProfile> fromGitHubBranch(final String branchName)
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) {
if (flavour == PDFAFlavour.NO_FLAVOUR || flavour == PDFAFlavour.NO_ARLINGTON_FLAVOUR ||
flavour.getPart().getFamily() == PDFAFlavour.SpecificationFamily.WCAG ||
flavour.getPart().getFamily() == PDFAFlavour.SpecificationFamily.WTPDF ||
flavour.getPart().getFamily() == PDFAFlavour.SpecificationFamily.ARLINGTON) {
continue;
}
String profileURLString = (flavour.getPart().getFamily() != PDFAFlavour.SpecificationFamily.PDF_UA ? PDFApathPrefix : PDFUApathPrefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
package org.verapdf.integration.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -36,12 +34,12 @@
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider;
import org.verapdf.pdfa.Foundries;
import org.verapdf.pdfa.results.ValidationResult;
import org.verapdf.pdfa.validation.profiles.ProfileDirectory;
import org.verapdf.pdfa.validation.profiles.Profiles;
import org.verapdf.pdfa.validation.profiles.RuleId;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.qa.*;
import org.verapdf.pdfa.qa.AbstractTestCorpus.Corpus;
import org.verapdf.pdfbox.foundry.PdfBoxFoundryProvider;
import org.yaml.snakeyaml.Yaml;

import com.github.mustachejava.DefaultMustacheFactory;
Expand All @@ -51,9 +49,7 @@
@SuppressWarnings({ "javadoc" })
public class CorpusTest {
private static ComponentDetails gfDetails;
private static ComponentDetails pdfBoxDetails;
private static final List<ResultSet> gfResults = new ArrayList<>();
private static final List<ResultSet> pdfBoxResults = new ArrayList<>();
private static final MustacheFactory MF = new DefaultMustacheFactory("org/verapdf/integration/templates");
private static final Mustache RESULTS_MUSTACHE = MF.compile("corpus-results.mustache");
private static final Mustache SUMMARY_MUSTACHE = MF.compile("test-summary.mustache");
Expand All @@ -79,21 +75,10 @@ public static void outputResults() throws IOException {
writeResults();
}

// @Test
public void testPdfBox() throws Exception {
PdfBoxFoundryProvider.initialise();
RegressionTestingHelper.printDependencies();
assertTrue(Foundries.defaultParserIsPDFBox());
pdfBoxDetails = Foundries.defaultInstance().getDetails();
test(pdfBoxResults, "org/verapdf/integration/tests/rules/corpus-pdfbox.yml");
collector.checkThat("Exceptions thrown during PDFBox testing.", countExceptions(pdfBoxResults), equalTo(0));
}

@Test
public void testGreenfield() throws Exception {
VeraGreenfieldFoundryProvider.initialise();
RegressionTestingHelper.printDependencies();
assertFalse(Foundries.defaultParserIsPDFBox());
gfDetails = Foundries.defaultInstance().getDetails();
testCorpora(gfResults);
// test(gfResults, "org/verapdf/integration/tests/rules/corpus-gf.yml");
Expand Down Expand Up @@ -205,9 +190,10 @@ private static int countExceptions(final List<ResultSet> resultSets) {
}

private static void testCorpora(final List<ResultSet> resultSets) {
ProfileDirectory directory = GitHubBackedProfileDirectory.fromBranch("integration");
for (PDFAFlavour flavour : CorpusManager.testableFlavours()) {
for (TestCorpus corpus : CorpusManager.corporaForFlavour(flavour)) {
ResultSet results = ResultSetImpl.validateCorpus(corpus, flavour != PDFAFlavour.NO_FLAVOUR ? Profiles.getVeraProfileDirectory().getValidationProfileByFlavour(flavour) : Profiles.defaultProfile());
ResultSet results = ResultSetImpl.validateCorpus(corpus, flavour != PDFAFlavour.NO_FLAVOUR ? directory.getValidationProfileByFlavour(flavour) : Profiles.defaultProfile());
resultSets.add(results);
}
}
Expand Down Expand Up @@ -252,10 +238,8 @@ private static void writeResults() throws IOException {
if (!rootDir.exists())
rootDir.mkdirs();
writeSummaries(rootDir);
int index = 0;
for (ResultSet gfResult : gfResults) {
Map<String, Object> scopes = new HashMap<>();
// scopes.put("pdfBoxResult", pdfBoxResult);
scopes.put("gfResult", gfResult);
scopes.put("profile", gfResult.getValidationProfile().getPDFAFlavour().getId());
if (rootDir.isDirectory() && rootDir.canWrite()) {
Expand All @@ -268,11 +252,9 @@ private static void writeResults() throws IOException {
}
}

private static void writeSummaries(final File outputDir) throws FileNotFoundException, IOException {
private static void writeSummaries(final File outputDir) throws IOException {
Map<String, Object> scopes = new HashMap<>();
// scopes.put("pdfBoxDetails", ResultSetDetailsImpl.getNewInstance(pdfBoxDetails));
scopes.put("gfDetails", ResultSetDetailsImpl.getNewInstance(gfDetails));
// scopes.put("pdfBoxResults", pdfBoxResults);
scopes.put("gfResults", gfResults);
try (Writer writer = new PrintWriter(new File(outputDir, "index.html"))) {
SUMMARY_MUSTACHE.execute(writer, scopes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheFactory;
import org.junit.Assert;
import org.junit.Test;
import org.verapdf.component.ComponentDetails;
import org.verapdf.core.EncryptedPdfException;
Expand All @@ -14,9 +13,7 @@
import org.verapdf.features.FeatureObjectType;
import org.verapdf.features.tools.FeatureTreeNode;
import org.verapdf.gf.model.GFModelParser;
import org.verapdf.model.ModelParser;
import org.verapdf.pdfa.Foundries;
import org.verapdf.pdfbox.foundry.PdfBoxFoundryProvider;
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.qa.FeatureTestResult;
Expand All @@ -42,7 +39,6 @@ public class FeatureTest {
"org/verapdf/integration/templates");
private static final Mustache SUMMARY_MUSTACHE = MF.compile("features-summary.mustache");
private static ComponentDetails gfDetails;
private static ComponentDetails pdfBoxDetails;
private static final File outputDir = new File("target/features-test-results");

private static Stack<String> failMessages = new Stack<>();
Expand Down Expand Up @@ -88,7 +84,6 @@ public static void outputResults() throws IOException {
rootDir.mkdirs();
}
Map<String, Object> scopes = new HashMap<>();
scopes.put("pdfBoxDetails", ResultSetDetailsImpl.getNewInstance(pdfBoxDetails));
scopes.put("gfDetails", ResultSetDetailsImpl.getNewInstance(gfDetails));
scopes.put("results", results);

Expand All @@ -97,8 +92,7 @@ public static void outputResults() throws IOException {
}
}

private void testFile(Map.Entry<String, FeatureObjectType> file)
throws ModelParsingException, EncryptedPdfException {
private void testFile(Map.Entry<String, FeatureObjectType> file) {
File testFile = new File(String.format(PATH_FORMAT, file.getKey()));
FeatureExtractorConfig config;
FeatureExtractionResult gfFeatures;
Expand All @@ -111,14 +105,6 @@ private void testFile(Map.Entry<String, FeatureObjectType> file)
LOGGER.log(Level.WARNING, "Exception during feature processing " + t.getMessage());
throw new RuntimeException("greenfield exception: " + t.getMessage(), t);
}
try {
initPdfboxFoundry();
ModelParser pbParser = ModelParser.createModelWithFlavour(testFile, PDFAFlavour.NO_FLAVOUR);
FeatureExtractionResult pbFeatures = pbParser.getFeatures(config);
Assert.assertTrue(featureExtractionResultsEqual(gfFeatures, pbFeatures, file.getValue()));
} catch (Throwable t) {
throw new RuntimeException("pdfbox exception: " + t.getMessage(), t);
}
}

private static boolean featureExtractionResultsEqual(FeatureExtractionResult res1,
Expand Down Expand Up @@ -205,13 +191,6 @@ private static void initGfFoundry() {
}
}

private static void initPdfboxFoundry() {
PdfBoxFoundryProvider.initialise();
if (pdfBoxDetails == null) {
pdfBoxDetails = Foundries.defaultInstance().getDetails();
}
}

// utility class for mustache
public class ThrowableMessageWrapper {
private Throwable e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import org.verapdf.core.ModelParsingException;
import org.verapdf.core.ValidationException;
import org.verapdf.core.XmlSerialiser;
import org.verapdf.model.ModelParser;
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider;
import org.verapdf.gf.model.GFModelParser;
import org.verapdf.pdfa.Foundries;
import org.verapdf.pdfa.PDFAParser;
import org.verapdf.pdfa.PDFAValidator;
import org.verapdf.pdfa.validation.validators.ValidatorBuilder;
import org.verapdf.pdfbox.foundry.PdfBoxFoundryProvider;
import org.verapdf.pdfa.flavours.PDFAFlavour;
import org.verapdf.pdfa.qa.AbstractTestCorpus.Corpus;
import org.verapdf.pdfa.qa.CorpusManager;
Expand Down Expand Up @@ -65,7 +65,7 @@ public class ValidatorTest {

@BeforeClass
public static final void SetUp() {
PdfBoxFoundryProvider.initialise();
VeraGreenfieldFoundryProvider.initialise();
}
/**
* Test method for
Expand Down Expand Up @@ -104,7 +104,7 @@ public final void testValidateValidationConsistency() throws IOException,
Set<ValidationResult> results = new HashSet<>();
// Validate a fresh model instance and add the result to the set
for (int index = 0; index < 2; index++) {
try (PDFAParser parser = ModelParser.createModelWithFlavour(
try (PDFAParser parser = GFModelParser.createModelWithFlavour(
veraCorpus.getItemStream(itemName), profile.getPDFAFlavour())) {
ValidationResult result = validator.validate(parser);
results.add(result);
Expand Down Expand Up @@ -136,7 +136,7 @@ public void testFailFastValidator() throws IOException, JAXBException, ModelPars
false);
ValidationResult result = ValidationResults.defaultResult();
// Validate a fresh model instance and add the result to the set
try (PDFAParser parser = ModelParser.createModelWithFlavour(
try (PDFAParser parser = GFModelParser.createModelWithFlavour(
veraCorpus.getItemStream(itemName), profile.getPDFAFlavour())) {
result = validator.validate(parser);
} catch (ValidationException e) {
Expand All @@ -148,7 +148,7 @@ public void testFailFastValidator() throws IOException, JAXBException, ModelPars
for (int index = failedMax; index > 0; index--) {
PDFAValidator fastFailValidator = new ValidatorBuilder().profile(profile).maxFails(index).build();
ValidationResult failFastResult = ValidationResults.defaultResult();
try (ModelParser parser = ModelParser.createModelWithFlavour(
try (GFModelParser parser = GFModelParser.createModelWithFlavour(
veraCorpus.getItemStream(itemName), profile.getPDFAFlavour())) {
failFastResult = fastFailValidator.validate(parser);
} catch (ValidationException e) {
Expand Down Expand Up @@ -201,7 +201,7 @@ public void testModelConsistency() throws IOException, ValidationException,
PDFAValidator checkValidator = Foundries.defaultInstance().createValidator(
profile, false);
// Create a new model parser instance
try (PDFAParser parser = ModelParser.createModelWithFlavour(
try (PDFAParser parser = GFModelParser.createModelWithFlavour(
veraCorpus.getItemStream(itemName), profile.getPDFAFlavour())) {
// Validate model with fresh validator
ValidationResult firstResult = validator.validate(parser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@

<!-- Header Row -->
<tr>
<th>
{{#pdfBoxResult}}
<h2>{{details.foundryDetails.name}} v{{details.foundryDetails.version}}</h2>
<h3>Dependencies</h3>
{{#details.dependencies}}
<p>{{id}} v{{version}}-{{buildDate}}</p>
{{/details.dependencies}}
{{/pdfBoxResult}}
</th>

<th>
{{#gfResult}}
<h2>{{details.foundryDetails.name}} v{{details.foundryDetails.version}}</h2>
Expand All @@ -66,42 +56,6 @@

<!-- Content Row -->
<tr>
<td>

<table id="pdfbox-results">
{{#pdfBoxResult.exceptions}}
<tr>
<td class="fail">{{corpusItemId.name}}</td>
</tr>
<tr>
<td class="trace">
<pre>
{{cause.message}}
{{#cause.stackTrace}}
{{className}}.{{methodName}}({{fileName}}:{{lineNumber}})
{{/cause.stackTrace}}
</pre>
</td>
</tr>
{{/pdfBoxResult.exceptions}}

{{#pdfBoxResult.results}}
{{#result}}
<tr>
<td class="{{testType}}">{{corpusItemName}}</td>
</tr>
<tr>
<td>
<pre>
Duration: {{duration}}
Memory: {{memoryUsed}} MB
</pre>
</td>
</tr>
{{/result}}
{{/pdfBoxResult.results}}
</table>
</td>
<td>

<table id="gf-results">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@
<body>

<div id="content" align="center">
<h1>Feature extraction tests: {{pdfBoxDetails.dateCreated}}</h1>
<h2>Check if greenfield results are equal to pdfbox result</h2>
<h1>Feature extraction tests: {{gfDetails.dateCreated}}</h1>

<div id="wrapper">
<table id="layout">
<!-- Header Row -->
<tr>
<th>
{{#pdfBoxDetails}}
{{#gfDetails}}
<h2>{{foundryDetails.name}} v{{foundryDetails.version}}</h2>
<h3>Dependencies</h3>
{{#dependencies}}
<p>{{id}} v{{version}}-{{buildDate}}</p>
{{/dependencies}}
{{/pdfBoxDetails}}
{{/gfDetails}}
</th>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,12 @@
<body>

<div id="content">
<h1>verPDF Corpus Integration Tests : {{pdfBoxDetails.dateCreated}}</h1>
<h1>verPDF Corpus Integration Tests : {{gfDetails.dateCreated}}</h1>

<div id="wrapper">
<table id="layout">
<!-- Header Row -->
<tr>
<th>
{{#pdfBoxDetails}}
<h2>{{foundryDetails.name}} v{{foundryDetails.version}}</h2>
<h3>Dependencies</h3>
{{#dependencies}}
<p>{{id}} v{{version}}-{{buildDate}}</p>
{{/dependencies}}
{{/pdfBoxDetails}}
</th>
<th>
{{#gfDetails}}
<h2>{{foundryDetails.name}} v{{foundryDetails.version}}</h2>
Expand All @@ -58,17 +49,6 @@

<!-- Summaries Row -->
<tr>
<td>
{{#pdfBoxResults}}
<h2 class="{{summary.passed}}"><a href="{{corpusDetails.name}}-{{validationProfile.PDFAFlavour.id}}/index.html" title="">{{corpusDetails.name}}-{{validationProfile.PDFAFlavour.id}}</a></h2>
<pre>
Valid Cases: {{summary.validCases}} | passed: {{summary.validCasesPassed}} | failed: {{summary.validCasesFailed}}
Invalid: {{summary.invalidCases}} | passed: {{summary.invalidCasesPassed}} | failed: {{summary.invalidCasesFailed}}
Time Taken: {{summary.duration.duration}} | Memory Used: {{summary.memoryUsed}} MB
Exceptions: {{summary.exceptions}} | Undefined: {{summary.undefinedCases}} | Not Applicable: {{summary.inapplicableCases}}
</pre>
{{/pdfBoxResults}}
</td>
<td>
{{#gfResults}}
<h2 class="{{summary.passed}}"><a href="{{corpusDetails.name}}-{{validationProfile.PDFAFlavour.id}}/index.html" title="">{{corpusDetails.name}}-{{validationProfile.PDFAFlavour.id}}</a></h2>
Expand Down
Loading
Loading