Skip to content

Commit 891ee04

Browse files
committed
Add integration tests. Fix test data
1 parent 89af1db commit 891ee04

16 files changed

Lines changed: 323 additions & 431 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
test:
14+
unit-tests:
1515
runs-on: ubuntu-latest
1616

1717
steps:
@@ -23,8 +23,25 @@ jobs:
2323
java-version: 11
2424
cache: maven
2525

26-
- name: Run tests
26+
- name: Run unit tests
2727
run: mvn test --batch-mode --fail-at-end
2828

29-
- name: Build uber JAR
30-
run: mvn package --batch-mode -DskipTests
29+
eyes-tests:
30+
runs-on: ubuntu-latest
31+
needs: unit-tests
32+
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- uses: actions/setup-java@v4
38+
with:
39+
distribution: temurin
40+
java-version: 11
41+
cache: maven
42+
43+
- name: Run Eyes integration tests
44+
if: env.APPLITOOLS_API_KEY != ''
45+
env:
46+
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
47+
run: mvn test --batch-mode -Peyes-tests

TestData/b/Lorem1.pdf

-7.48 KB
Binary file not shown.

TestData/b/c/JustPDF/Lorem2.pdf

-7.48 KB
Binary file not shown.

TestData/b/c/JustPDF/Lorem3.pdf

-40.9 KB
Binary file not shown.

TestData/image-T0MP130031-01.png

48.9 KB
Loading

TestData/image-T0MP130031-01.tif

8.06 KB
Binary file not shown.

pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,26 @@
202202
</plugin>
203203
</plugins>
204204
</build>
205+
206+
<profiles>
207+
<profile>
208+
<id>eyes-tests</id>
209+
<build>
210+
<plugins>
211+
<plugin>
212+
<groupId>org.apache.maven.plugins</groupId>
213+
<artifactId>maven-surefire-plugin</artifactId>
214+
<configuration>
215+
<excludes combine.self="override" />
216+
<includes>
217+
<include>Tests/**</include>
218+
</includes>
219+
<parallel>methods</parallel>
220+
<threadCount>4</threadCount>
221+
</configuration>
222+
</plugin>
223+
</plugins>
224+
</build>
225+
</profile>
226+
</profiles>
205227
</project>

src/main/java/com/applitools/imagetester/ImageTester.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,11 @@ public static void main(String[] args) {
149149
suite.run();
150150

151151
config.closeBatches();
152-
153-
System.exit(0);
154152
} catch (ParseException | IOException e) {
155153
logger.reportException(e);
156154
logger.printHelp(options);
157-
System.exit(-1);
158155
} catch (NoSuchAlgorithmException | KeyManagementException e) {
159156
logger.reportException(e);
160-
System.exit(-1);
161157
}
162158
}
163159

@@ -283,8 +279,6 @@ private static void runTestWithBatchMapper(final Logger logger, final CommandLin
283279
} catch (Exception e) {
284280
logger.reportException(e);
285281
e.printStackTrace();
286-
} finally {
287-
System.exit(0);
288282
}
289283
}
290284

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package com.applitools.imagetester.demo;
2+
3+
import org.apache.pdfbox.pdmodel.PDDocument;
4+
import org.apache.pdfbox.pdmodel.PDPage;
5+
import org.apache.pdfbox.pdmodel.PDPageContentStream;
6+
import org.apache.pdfbox.pdmodel.common.PDRectangle;
7+
import org.apache.pdfbox.pdmodel.font.PDType1Font;
8+
9+
import java.io.File;
10+
import java.io.IOException;
11+
12+
/**
13+
* Generates sample PDFs for the BatchMapper demo.
14+
*
15+
* Run from the project root with:
16+
* mvn exec:java -Dexec.mainClass="com.applitools.imagetester.demo.GenerateDemoPDFs"
17+
*
18+
* Output files:
19+
* demo/batchmapper/before/contract.pdf — original 4-page contract
20+
* demo/batchmapper/after/contract.pdf — updated 5-page contract (page inserted after page 2)
21+
*/
22+
public class GenerateDemoPDFs {
23+
24+
public static void main(String[] args) throws IOException {
25+
createBeforePdf("demo/batchmapper/before/contract.pdf");
26+
createAfterPdf("demo/batchmapper/after/contract.pdf");
27+
System.out.println("Done. PDFs written to demo/batchmapper/before/ and demo/batchmapper/after/");
28+
}
29+
30+
// -----------------------------------------------------------------------
31+
// Before: 4 pages
32+
// Page 1 — Cover
33+
// Page 2 — Introduction
34+
// Page 3 — Details
35+
// Page 4 — Conclusion
36+
// -----------------------------------------------------------------------
37+
private static void createBeforePdf(String outputPath) throws IOException {
38+
new File(outputPath).getParentFile().mkdirs();
39+
try (PDDocument doc = new PDDocument()) {
40+
addPage(doc, "CONTRACT", "Page 1 of 4",
41+
"Service Agreement",
42+
"This document outlines the terms and conditions between",
43+
"Acme Corp and its client for professional services rendered.");
44+
45+
addPage(doc, "INTRODUCTION", "Page 2 of 4",
46+
"1. Background",
47+
"Acme Corp has been providing enterprise solutions since 2010.",
48+
"This agreement governs the scope of work described herein.");
49+
50+
addPage(doc, "DETAILS", "Page 3 of 4",
51+
"2. Scope of Work",
52+
"The vendor shall deliver software integration services",
53+
"as outlined in Exhibit A, within the agreed timeline.");
54+
55+
addPage(doc, "CONCLUSION", "Page 4 of 4",
56+
"3. Signatures",
57+
"By signing below, both parties agree to the terms set forth",
58+
"in this contract. Effective date: January 1, 2025.");
59+
60+
doc.save(outputPath);
61+
}
62+
System.out.println("Created: " + outputPath);
63+
}
64+
65+
// -----------------------------------------------------------------------
66+
// After: 5 pages — new page inserted between Introduction and Details
67+
// Page 1 — Cover (unchanged)
68+
// Page 2 — Introduction (unchanged)
69+
// Page 3 — NEW: Compliance Notice <-- inserted here
70+
// Page 4 — Details (was page 3)
71+
// Page 5 — Conclusion (was page 4)
72+
// -----------------------------------------------------------------------
73+
private static void createAfterPdf(String outputPath) throws IOException {
74+
new File(outputPath).getParentFile().mkdirs();
75+
try (PDDocument doc = new PDDocument()) {
76+
addPage(doc, "CONTRACT", "Page 1 of 5",
77+
"Service Agreement",
78+
"This document outlines the terms and conditions between",
79+
"Acme Corp and its client for professional services rendered.");
80+
81+
addPage(doc, "INTRODUCTION", "Page 2 of 5",
82+
"1. Background",
83+
"Acme Corp has been providing enterprise solutions since 2010.",
84+
"This agreement governs the scope of work described herein.");
85+
86+
addPage(doc, "COMPLIANCE NOTICE", "Page 3 of 5 *** NEW PAGE ***",
87+
"1a. Regulatory Compliance",
88+
"All services are subject to compliance with applicable data",
89+
"protection regulations including GDPR and CCPA.");
90+
91+
addPage(doc, "DETAILS", "Page 4 of 5",
92+
"2. Scope of Work",
93+
"The vendor shall deliver software integration services",
94+
"as outlined in Exhibit A, within the agreed timeline.");
95+
96+
addPage(doc, "CONCLUSION", "Page 5 of 5",
97+
"3. Signatures",
98+
"By signing below, both parties agree to the terms set forth",
99+
"in this contract. Effective date: January 1, 2025.");
100+
101+
doc.save(outputPath);
102+
}
103+
System.out.println("Created: " + outputPath);
104+
}
105+
106+
private static void addPage(PDDocument doc, String heading, String subheading,
107+
String section, String line1, String line2) throws IOException {
108+
PDPage page = new PDPage(PDRectangle.LETTER);
109+
doc.addPage(page);
110+
111+
try (PDPageContentStream cs = new PDPageContentStream(doc, page)) {
112+
float margin = 72;
113+
float width = page.getMediaBox().getWidth() - 2 * margin;
114+
float y = page.getMediaBox().getHeight() - margin;
115+
116+
// Heading
117+
cs.beginText();
118+
cs.setFont(PDType1Font.HELVETICA_BOLD, 28);
119+
cs.newLineAtOffset(margin, y - 40);
120+
cs.showText(heading);
121+
cs.endText();
122+
123+
// Subheading
124+
cs.beginText();
125+
cs.setFont(PDType1Font.HELVETICA, 12);
126+
cs.newLineAtOffset(margin, y - 70);
127+
cs.showText(subheading);
128+
cs.endText();
129+
130+
// Divider line (drawn as a thin rectangle)
131+
cs.setLineWidth(0.5f);
132+
cs.moveTo(margin, y - 85);
133+
cs.lineTo(margin + width, y - 85);
134+
cs.stroke();
135+
136+
// Body text
137+
cs.beginText();
138+
cs.setFont(PDType1Font.HELVETICA_BOLD, 14);
139+
cs.newLineAtOffset(margin, y - 120);
140+
cs.showText(section);
141+
cs.endText();
142+
143+
cs.beginText();
144+
cs.setFont(PDType1Font.HELVETICA, 12);
145+
cs.setLeading(20f);
146+
cs.newLineAtOffset(margin, y - 150);
147+
cs.showText(line1);
148+
cs.newLine();
149+
cs.showText(line2);
150+
cs.endText();
151+
}
152+
}
153+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package Tests;
2+
3+
import infra.TestBase;
4+
import org.junit.Test;
5+
6+
import com.applitools.imagetester.ImageTester;
7+
8+
/**
9+
* End-to-end Eyes integration tests. Requires APPLITOOLS_API_KEY env var.
10+
* Run with: mvn test -Peyes-tests
11+
*/
12+
public class EyesIntegrationTest extends TestBase {
13+
14+
// --- Single file tests ---
15+
16+
@Test
17+
public void singlePdf() {
18+
ImageTester.main("-f TestData/b/c/JustPDF/Lorem2.pdf".split(" "));
19+
}
20+
21+
@Test
22+
public void singleImage() {
23+
ImageTester.main("-f TestData/b/c/googleforgoogle.png".split(" "));
24+
}
25+
26+
// --- Folder tests ---
27+
28+
@Test
29+
public void folderWithMixedContent() {
30+
ImageTester.main("-f TestData/b/c -th 10".split(" "));
31+
}
32+
33+
@Test
34+
public void imageFolder() {
35+
ImageTester.main("-f TestData/a/".split(" "));
36+
}
37+
38+
@Test
39+
public void pdfFolder() {
40+
ImageTester.main("-f TestData/b/c/JustPDF/".split(" "));
41+
}
42+
43+
// --- Split mode ---
44+
45+
@Test
46+
public void pdfSplitMode() {
47+
ImageTester.main("-f TestData/b/c/JustPDF/Lorem3.pdf -st -th 10".split(" "));
48+
}
49+
50+
// --- Page selection ---
51+
52+
@Test
53+
public void pdfPageSelection() {
54+
ImageTester.main("-f TestData/b/c/JustPDF/Lorem3.pdf -sp 1-2 -th 10".split(" "));
55+
}
56+
57+
// --- Forced name ---
58+
59+
@Test
60+
public void forcedName() {
61+
ImageTester.main("-f TestData/b/Lorem1.pdf -fn MyForcedName".split(" "));
62+
}
63+
64+
// --- Flat batch ---
65+
66+
@Test
67+
public void flatBatchWithId() {
68+
ImageTester.main("-f TestData/b/Lorem1.pdf -fb TestBatch<>testBatchId".split(" "));
69+
}
70+
71+
// --- Batch notifications ---
72+
73+
@Test
74+
public void batchNotification() {
75+
ImageTester.main("-f TestData/b/c/JustPDF/Lorem2.pdf -nc".split(" "));
76+
}
77+
78+
// --- Image scaling ---
79+
80+
@Test
81+
public void imageScaling() {
82+
ImageTester.main("-f TestData/a/ -ms 1000x1000".split(" "));
83+
}
84+
85+
// --- Image cut ---
86+
87+
@Test
88+
public void imageCut() {
89+
ImageTester.main("-f TestData/a/ -ic 10,20,30,40".split(" "));
90+
}
91+
92+
// --- Ordering ---
93+
94+
@Test
95+
public void imageOrderAlphabetic() {
96+
ImageTester.main("-f TestData/jpegs/alphabetic".split(" "));
97+
}
98+
99+
@Test
100+
public void imageOrderMixed() {
101+
ImageTester.main("-f TestData/jpegs/mixed".split(" "));
102+
}
103+
104+
// --- Accessibility ---
105+
106+
@Test
107+
public void accessibilityWithRegions() {
108+
ImageTester.main("-f TestData/b/Lorem1.pdf -ac AAA -ari \"100,100,100,100\" -arr \"200,200,200,200\"".split(" "));
109+
}
110+
111+
// --- Regions ---
112+
113+
@Test
114+
public void ignoreContentLayoutRegions() {
115+
ImageTester.main("-f TestData/b/Lorem1.pdf -ir \"100,100,100,100\" -cr \"200,200,200,200\" -lr \"300,300,300,300\"".split(" "));
116+
}
117+
118+
// --- Whitebox: multithreaded folder ---
119+
120+
@Test
121+
public void multithreadedFolderTraversal() {
122+
runWhitebox("FolderTestsApp", "TestData/b");
123+
}
124+
}

0 commit comments

Comments
 (0)