diff --git a/flying-saucer-core/pom.xml b/flying-saucer-core/pom.xml
index decb26c66..e540e08ad 100644
--- a/flying-saucer-core/pom.xml
+++ b/flying-saucer-core/pom.xml
@@ -8,6 +8,7 @@
org.xhtmlrenderer
flying-saucer-parent
9.3.2-SNAPSHOT
+ ../pom.xml
flying-saucer-core
diff --git a/flying-saucer-core/src/test/java/org/xhtmlrenderer/css/parser/ParserTest.java b/flying-saucer-core/src/test/java/org/xhtmlrenderer/css/parser/ParserTest.java
index e2d61d4c5..ba31a1eaf 100644
--- a/flying-saucer-core/src/test/java/org/xhtmlrenderer/css/parser/ParserTest.java
+++ b/flying-saucer-core/src/test/java/org/xhtmlrenderer/css/parser/ParserTest.java
@@ -19,8 +19,7 @@
*/
package org.xhtmlrenderer.css.parser;
-import junit.framework.TestCase;
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
import org.xhtmlrenderer.css.newmatch.Selector;
import org.xhtmlrenderer.css.sheet.PropertyDeclaration;
import org.xhtmlrenderer.css.sheet.Ruleset;
@@ -29,17 +28,20 @@
import java.io.IOException;
import java.io.StringReader;
-public class ParserTest extends TestCase {
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ParserTest {
private final String test = String.format("div { background-image: url('something') }%n");
private final CSSErrorHandler errorHandler = (uri, message) -> System.out.println(message);
- public void test_cssParsingPerformance() throws IOException {
+ @Test
+ public void cssParsingPerformance() throws IOException {
int count = 10_000;
StringBuilder longTest = new StringBuilder();
for (int i = 0 ; i < count; i++) {
longTest.append(test);
}
- Assert.assertEquals("Long enough input", test.length() * count, longTest.length());
+ assertThat(longTest.length()).as("Long enough input").isEqualTo(test.length() * count);
long total = 0;
for (int i = 0; i < 40; i++) {
@@ -50,7 +52,7 @@ public void test_cssParsingPerformance() throws IOException {
// System.out.println("Took " + (end-start) + " ms");
total += (end-start);
- assertEquals(count, stylesheet.getContents().size());
+ assertThat(stylesheet.getContents()).hasSize(count);
}
System.out.println("Average " + (total/10) + " ms");
@@ -62,7 +64,7 @@ public void test_cssParsingPerformance() throws IOException {
long end = System.currentTimeMillis();
// System.out.println("Took " + (end-start) + " ms");
total += (end-start);
- assertEquals(count, stylesheet.getContents().size());
+ assertThat(stylesheet.getContents()).hasSize(count);
}
System.out.println("Average " + (total/10) + " ms");
@@ -81,18 +83,19 @@ public void test_cssParsingPerformance() throws IOException {
System.out.println("Average " + (total/10) + " ms");
}
- public void test_parseCss() throws IOException {
+ @Test
+ public void parseCss() throws IOException {
CSSParser p = new CSSParser(errorHandler);
-
+
Stylesheet stylesheet = p.parseStylesheet(null, 0, new StringReader(test));
- assertEquals(1, stylesheet.getContents().size());
+ assertThat(stylesheet.getContents()).hasSize(1);
Ruleset ruleset = (Ruleset) stylesheet.getContents().get(0);
- assertEquals(1, ruleset.getFSSelectors().size());
- assertEquals(Selector.class, ruleset.getFSSelectors().get(0).getClass());
- assertEquals(1, ruleset.getPropertyDeclarations().size());
- PropertyDeclaration propertyDeclaration = (PropertyDeclaration) ruleset.getPropertyDeclarations().get(0);
- assertEquals("background-image", propertyDeclaration.getPropertyName());
- assertEquals("background-image", propertyDeclaration.getCSSName().toString());
- assertEquals("url('something')", propertyDeclaration.getValue().getCssText());
+ org.assertj.core.api.Assertions.assertThat(ruleset.getFSSelectors()).hasSize(1);
+ assertThat(ruleset.getFSSelectors().get(0)).isInstanceOf(Selector.class);
+ org.assertj.core.api.Assertions.assertThat(ruleset.getPropertyDeclarations()).hasSize(1);
+ PropertyDeclaration propertyDeclaration = ruleset.getPropertyDeclarations().get(0);
+ assertThat(propertyDeclaration.getPropertyName()).isEqualTo("background-image");
+ assertThat(propertyDeclaration.getCSSName()).hasToString("background-image");
+ assertThat(propertyDeclaration.getValue().getCssText()).isEqualTo("url('something')");
}
}
diff --git a/flying-saucer-core/src/test/java/org/xhtmlrenderer/layout/breaker/UrlAwareLineBreakIteratorTest.java b/flying-saucer-core/src/test/java/org/xhtmlrenderer/layout/breaker/UrlAwareLineBreakIteratorTest.java
index 73f0af251..311b05250 100644
--- a/flying-saucer-core/src/test/java/org/xhtmlrenderer/layout/breaker/UrlAwareLineBreakIteratorTest.java
+++ b/flying-saucer-core/src/test/java/org/xhtmlrenderer/layout/breaker/UrlAwareLineBreakIteratorTest.java
@@ -1,105 +1,108 @@
package org.xhtmlrenderer.layout.breaker;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
import java.text.BreakIterator;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
-public class UrlAwareLineBreakIteratorTest extends TestCase {
+public class UrlAwareLineBreakIteratorTest {
- public void testNext_BreakAtSpace() {
+ @Test
+ public void breakAtSpace() {
assertBreaksCorrectly("Hello World! World foo",
new String[] {"Hello ", "World! ", "World ", "foo"});
}
-
- public void testNext_BreakAtPunctuation() {
+ @Test
+ public void breakAtPunctuation() {
assertBreaksCorrectly("The.quick,brown:fox;jumps!over?the(lazy)[dog]",
new String[] {"The.", "quick,", "brown:", "fox;", "jumps!", "over?", "the", "(lazy)", "[dog]"});
}
-
- public void testNext_BreakAtHyphen() {
+ @Test
+ public void breakAtHyphen() {
assertBreaksCorrectly("Pseudo-element",
new String[] {"Pseudo-", "element"});
}
-
- public void testNext_BreakAtSlash() {
+ @Test
+ public void breakAtSlash() {
assertBreaksCorrectly("Justice/Law",
new String[] {"Justice", "/Law"});
}
-
- public void testNext_WordBeginsWithSlash() {
+ @Test
+ public void wordBeginsWithSlash() {
assertBreaksCorrectly("Justice /Law",
new String[] {"Justice ", "/Law"});
}
-
- public void testNext_WordEndsWithSlash() {
+ @Test
+ public void wordEndsWithSlash() {
assertBreaksCorrectly("Justice/ Law",
new String[] {"Justice/ ", "Law"});
}
-
- public void testNext_WordEndsWithSlashMultipleWhitespace() {
+ @Test
+ public void wordEndsWithSlashMultipleWhitespace() {
assertBreaksCorrectly("Justice/ Law",
new String[] {"Justice/ ", "Law"});
}
-
- public void testNext_SlashSeparatedSequence() {
+ @Test
+ public void slashSeparatedSequence() {
assertBreaksCorrectly("/this/is/a/long/path/name/",
new String[] {"/this", "/is", "/a", "/long", "/path", "/name/"});
}
-
- public void testNext_UrlInside() {
+ @Test
+ public void urlInside() {
assertBreaksCorrectly("Sentence with url https://github.com/flyingsaucerproject/flyingsaucer?test=true¶m2=false inside.",
new String[] {"Sentence ", "with ", "url ", "https://github.", "com", "/flyingsaucerproject", "/flyingsaucer?",
"test=true¶m2=false ", "inside."});
}
-
- public void testNext_MultipleSlashesInWord() {
+ @Test
+ public void multipleSlashesInWord() {
assertBreaksCorrectly("word/////word",
new String[] {"word", "/////word"});
}
-
- public void testNext_MultipleSlashesBeforeWord() {
+ @Test
+ public void multipleSlashesBeforeWord() {
assertBreaksCorrectly("hello /////world",
new String[] {"hello ", "/////world"});
}
-
- public void testNext_MultipleSlashesAfterWord() {
+ @Test
+ public void multipleSlashesAfterWord() {
assertBreaksCorrectly("hello world/////",
new String[] {"hello ", "world/////"});
}
-
- public void testNext_MultipleSlashesAroundWord() {
+ @Test
+ public void multipleSlashesAroundWord() {
assertBreaksCorrectly("hello /////world/////",
new String[] {"hello ", "/////world/////"});
}
-
- public void testNext_WhitespaceAfterTrailingSlashes() {
+ @Test
+ public void whitespaceAfterTrailingSlashes() {
assertBreaksCorrectly("hello world/// ",
new String[] {"hello ", "world/// "});
}
-
- public void testNext_ShortUrl() {
+ @Test
+ public void shortUrl() {
assertBreaksCorrectly("http://localhost",
new String[] {"http://localhost"});
}
-
- public void testNext_IncompleteUrl() {
- assertBreaksCorrectly("http://",
+ @Test
+ public void incompleteUrl() {
+ assertBreaksCorrectly("http://",
new String[] {"http://"});
}
@@ -113,13 +116,15 @@ private void assertBreaksCorrectly(String input, String[] segments) {
while ((breakpoint = iterator.next()) != BreakIterator.DONE) {
if (segmentIndex < segments.length) {
String segment = segments[segmentIndex++];
- assertEquals("Segment #" + segmentIndex + " does not match.", segment, input.substring(lastBreakPoint, breakpoint));
+ assertThat(input.substring(lastBreakPoint, breakpoint))
+ .as("Segment #" + segmentIndex + " does not match.")
+ .isEqualTo(segment);
lastBreakPoint = breakpoint;
} else {
fail("Too few segments.");
}
}
- assertEquals("Last breakpoint is wrong.", input.length(), lastBreakPoint);
+ assertThat(lastBreakPoint).as("Last breakpoint is wrong.").isEqualTo(input.length());
if (segmentIndex != segments.length) {
fail("Too many segments.");
}
diff --git a/flying-saucer-core/src/test/java/org/xhtmlrenderer/simple/Graphics2DRendererTest.java b/flying-saucer-core/src/test/java/org/xhtmlrenderer/simple/Graphics2DRendererTest.java
index 33518f2fe..2a9072688 100644
--- a/flying-saucer-core/src/test/java/org/xhtmlrenderer/simple/Graphics2DRendererTest.java
+++ b/flying-saucer-core/src/test/java/org/xhtmlrenderer/simple/Graphics2DRendererTest.java
@@ -1,6 +1,6 @@
package org.xhtmlrenderer.simple;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/flying-saucer-core/src/test/java/org/xhtmlrenderer/swing/NaiveUserAgentTest.java b/flying-saucer-core/src/test/java/org/xhtmlrenderer/swing/NaiveUserAgentTest.java
index 0a3ec3926..8a1d4f3c2 100644
--- a/flying-saucer-core/src/test/java/org/xhtmlrenderer/swing/NaiveUserAgentTest.java
+++ b/flying-saucer-core/src/test/java/org/xhtmlrenderer/swing/NaiveUserAgentTest.java
@@ -1,66 +1,66 @@
package org.xhtmlrenderer.swing;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class NaiveUserAgentTest
- extends TestCase
-{
- private static String resolve(String baseUri, String uri)
- {
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class NaiveUserAgentTest {
+ private static String resolve(String baseUri, String uri) {
NaiveUserAgent userAgent=new NaiveUserAgent();
userAgent.setBaseURL(baseUri);
return userAgent.resolveURI(uri);
}
- public void testBasicResolve()
- {
+ @Test
+ public void basicResolve() {
// absolute uris should be unchanged
- assertEquals("http://www.example.com", resolve(null, "http://www.example.com"));
- assertEquals("http://www.example.com", resolve("ftp://www.example.com/other","http://www.example.com"));
+ assertThat(resolve(null, "http://www.example.com")).isEqualTo("http://www.example.com");
+ assertThat(resolve("ftp://www.example.com/other", "http://www.example.com")).isEqualTo("http://www.example.com");
// by default relative uris resolves as file
- assertNotNull(resolve(null, "www.example.com"));
- assertTrue(resolve(null, "www.example.com").startsWith("file:"));
+ assertThat(resolve(null, "www.example.com"))
+ .isNotNull()
+ .startsWith("file:");
// relative uris without slash
- assertEquals("ftp://www.example.com/test", resolve("ftp://www.example.com/other","test"));
+ assertThat(resolve("ftp://www.example.com/other", "test")).isEqualTo("ftp://www.example.com/test");
// relative uris with slash
- assertEquals("ftp://www.example.com/other/test", resolve("ftp://www.example.com/other/","test"));
- assertEquals("ftp://www.example.com/test", resolve("ftp://www.example.com/other/","/test"));
+ assertThat(resolve("ftp://www.example.com/other/", "test")).isEqualTo("ftp://www.example.com/other/test");
+ assertThat(resolve("ftp://www.example.com/other/", "/test")).isEqualTo("ftp://www.example.com/test");
}
- public void testCustomProtocolResolve()
- {
+ @Test
+ public void customProtocolResolve() {
// absolute uris should be unchanged
- assertEquals("custom://www.example.com", resolve(null, "custom://www.example.com"));
- assertEquals("custom://www.example.com", resolve("ftp://www.example.com/other","custom://www.example.com"));
+ assertThat(resolve(null, "custom://www.example.com")).isEqualTo("custom://www.example.com");
+ assertThat(resolve("ftp://www.example.com/other", "custom://www.example.com")).isEqualTo("custom://www.example.com");
// relative uris without slash
- assertEquals("custom://www.example.com/test", resolve("custom://www.example.com/other","test"));
+ assertThat(resolve("custom://www.example.com/other", "test")).isEqualTo("custom://www.example.com/test");
// relative uris with slash
- assertEquals("custom://www.example.com/other/test", resolve("custom://www.example.com/other/","test"));
- assertEquals("custom://www.example.com/test", resolve("custom://www.example.com/other/","/test"));
+ assertThat(resolve("custom://www.example.com/other/", "test")).isEqualTo("custom://www.example.com/other/test");
+ assertThat(resolve("custom://www.example.com/other/", "/test")).isEqualTo("custom://www.example.com/test");
}
/**
- * This reproduces https://code.google.com/archive/p/flying-saucer/issues/262
- *
+ * This reproduces ...
+ *
* Below test was green with 9.0.6 and turned red in 9.0.7
*/
- public void testJarFileUriResolve()
- {
+ @Test
+ public void jarFileUriResolve() {
// absolute uris should be unchanged
- assertEquals("jar:file:/path/jarfile.jar!/foo/index.xhtml", resolve(null, "jar:file:/path/jarfile.jar!/foo/index.xhtml"));
- assertEquals("jar:file:/path/jarfile.jar!/foo/index.xhtml", resolve("ftp://www.example.com/other","jar:file:/path/jarfile.jar!/foo/index.xhtml"));
+ assertThat(resolve(null, "jar:file:/path/jarfile.jar!/foo/index.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/index.xhtml");
+ assertThat(resolve("ftp://www.example.com/other", "jar:file:/path/jarfile.jar!/foo/index.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/index.xhtml");
// relative uris without slash
- assertEquals("jar:file:/path/jarfile.jar!/foo/other.xhtml", resolve("jar:file:/path/jarfile.jar!/foo/index.xhtml","other.xhtml"));
+ assertThat(resolve("jar:file:/path/jarfile.jar!/foo/index.xhtml", "other.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/other.xhtml");
// relative uris with slash
- assertEquals("jar:file:/path/jarfile.jar!/foo/other.xhtml", resolve("jar:file:/path/jarfile.jar!/foo/","other.xhtml"));
- assertEquals("jar:file:/path/jarfile.jar!/other.xhtml", resolve("jar:file:/path/jarfile.jar!/foo/","/other.xhtml"));
+ assertThat(resolve("jar:file:/path/jarfile.jar!/foo/", "other.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/foo/other.xhtml");
+ assertThat(resolve("jar:file:/path/jarfile.jar!/foo/", "/other.xhtml")).isEqualTo("jar:file:/path/jarfile.jar!/other.xhtml");
}
}
diff --git a/flying-saucer-core/src/test/java/org/xhtmlrenderer/util/ConfigurationTest.java b/flying-saucer-core/src/test/java/org/xhtmlrenderer/util/ConfigurationTest.java
index be914ac89..e7c3edc6c 100644
--- a/flying-saucer-core/src/test/java/org/xhtmlrenderer/util/ConfigurationTest.java
+++ b/flying-saucer-core/src/test/java/org/xhtmlrenderer/util/ConfigurationTest.java
@@ -1,6 +1,6 @@
package org.xhtmlrenderer.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/flying-saucer-examples/pom.xml b/flying-saucer-examples/pom.xml
index a2bbf4cfe..acef03b4c 100644
--- a/flying-saucer-examples/pom.xml
+++ b/flying-saucer-examples/pom.xml
@@ -7,6 +7,7 @@
org.xhtmlrenderer
flying-saucer-parent
9.3.2-SNAPSHOT
+ ../pom.xml
flying-saucer-examples
@@ -39,12 +40,6 @@
flying-saucer-pdf
${project.version}
-
- com.codeborne
- pdf-test
- ${pdftest.version}
- test
-
diff --git a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/ConcurrentPdfGenerationTest.java b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/ConcurrentPdfGenerationTest.java
index 55f3919a9..ef9317ab9 100644
--- a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/ConcurrentPdfGenerationTest.java
+++ b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/ConcurrentPdfGenerationTest.java
@@ -2,7 +2,7 @@
import com.codeborne.pdftest.PDF;
import com.lowagie.text.DocumentException;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -27,15 +27,17 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
-public class ConcurrentPdfGenerationTest extends TestCase {
+public class ConcurrentPdfGenerationTest {
private static final Logger log = LoggerFactory.getLogger(ConcurrentPdfGenerationTest.class);
-
- public void testSamplePdf() {
+
+ @Test
+ public void samplePdf() {
byte[] pdf = generatePdf("sample.html");
verifyPdf(pdf);
}
- public void testConcurrentPdfGeneration() throws InterruptedException {
+ @Test
+ public void concurrentPdfGeneration() throws InterruptedException {
ScheduledExecutorService timer = newScheduledThreadPool(1);
timer.scheduleWithFixedDelay(System::gc, 0, 15, MILLISECONDS);
diff --git a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderTest.java b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderTest.java
index fda1f282a..4e6f89f19 100644
--- a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderTest.java
+++ b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderTest.java
@@ -2,13 +2,14 @@
import com.codeborne.pdftest.PDF;
import com.lowagie.text.DocumentException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.xhtmlrenderer.resource.XMLResource;
import org.xml.sax.InputSource;
+import javax.annotation.ParametersAreNonnullByDefault;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -24,7 +25,7 @@ public class PDFRenderTest {
private static final Logger log = LoggerFactory.getLogger(PDFRenderTest.class);
@Test
- public void testConvertSimpleHtmlToPdf() throws IOException, DocumentException {
+ public void convertSimpleHtmlToPdf() throws IOException, DocumentException {
URL source = requireNonNull(Thread.currentThread().getContextClassLoader().getResource("hello.html"));
File output = File.createTempFile("flying-saucer-" + getClass().getSimpleName(), ".hello.pdf");
PDF pdf = generatePDF(source, output);
@@ -32,7 +33,7 @@ public void testConvertSimpleHtmlToPdf() throws IOException, DocumentException {
}
@Test
- public void testConvertComplexHtmlToPdf() throws IOException, DocumentException {
+ public void convertComplexHtmlToPdf() throws IOException, DocumentException {
URL source = requireNonNull(Thread.currentThread().getContextClassLoader().getResource("hamlet.xhtml"));
File output = File.createTempFile("flying-saucer-" + getClass().getSimpleName(), ".hamlet.pdf");
PDF pdf = generatePDF(source, output);
@@ -66,6 +67,7 @@ private static PDF generatePDF(URL source, File output) throws IOException, Docu
return new PDF(output);
}
+ @ParametersAreNonnullByDefault
private static class ResourceLoaderUserAgent extends ITextUserAgent {
private ResourceLoaderUserAgent(ITextOutputDevice outputDevice) {
super(outputDevice);
diff --git a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderToMultiplePagesTest.java b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderToMultiplePagesTest.java
index 32b78c427..e64c85782 100644
--- a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderToMultiplePagesTest.java
+++ b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/PDFRenderToMultiplePagesTest.java
@@ -2,7 +2,7 @@
import com.codeborne.pdftest.PDF;
import com.lowagie.text.DocumentException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,7 +20,7 @@ public class PDFRenderToMultiplePagesTest {
private static final Logger log = LoggerFactory.getLogger(PDFRenderToMultiplePagesTest.class);
@Test
- public void testGenerateSinglePdfFromMultipleInputDocuments() throws Exception {
+ public void generateSinglePdfFromMultipleInputDocuments() throws Exception {
File output = File.createTempFile("flying-saucer-" + getClass().getSimpleName(), ".pdf");
String[] inputs = createSimpleFakeDocuments();
generatePDF(inputs, output);
diff --git a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/SimpleHtmlTest.java b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/SimpleHtmlTest.java
index 0175ab6b8..ec93f4981 100644
--- a/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/SimpleHtmlTest.java
+++ b/flying-saucer-examples/src/test/java/org/xhtmlrenderer/pdf/SimpleHtmlTest.java
@@ -1,8 +1,9 @@
package org.xhtmlrenderer.pdf;
+import com.codeborne.pdftest.PDF;
import com.lowagie.text.DocumentException;
-import junit.framework.TestCase;
import org.apache.pdfbox.io.IOUtils;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -12,10 +13,13 @@
import java.io.FileOutputStream;
import java.io.IOException;
-public class SimpleHtmlTest extends TestCase {
+import static com.codeborne.pdftest.assertj.Assertions.assertThat;
+
+public class SimpleHtmlTest {
private static final Logger log = LoggerFactory.getLogger(SimpleHtmlTest.class);
- public void testSimplePdf() throws DocumentException, IOException {
+ @Test
+ public void simplePdf() throws DocumentException, IOException {
ITextRenderer renderer = new ITextRenderer();
String htmlContent = "My First Heading
My first paragraph.
";
@@ -32,5 +36,8 @@ public void testSimplePdf() throws DocumentException, IOException {
IOUtils.copy(new ByteArrayInputStream(outputStream.toByteArray()), o);
}
log.info("Generated PDF: {}", file.getAbsolutePath());
+
+ PDF pdf = new PDF(file);
+ assertThat(pdf).containsText("My First Heading", "My first paragraph");
}
}
diff --git a/flying-saucer-fop/pom.xml b/flying-saucer-fop/pom.xml
index fd9367365..8f1bdd20b 100644
--- a/flying-saucer-fop/pom.xml
+++ b/flying-saucer-fop/pom.xml
@@ -8,6 +8,7 @@
org.xhtmlrenderer
flying-saucer-parent
9.3.2-SNAPSHOT
+ ../pom.xml
flying-saucer-fop
diff --git a/flying-saucer-fop/src/test/java/org/xhtmlrenderer/fop/PDFHyphenationTest.java b/flying-saucer-fop/src/test/java/org/xhtmlrenderer/fop/PDFHyphenationTest.java
index bf9bde26d..f19682993 100644
--- a/flying-saucer-fop/src/test/java/org/xhtmlrenderer/fop/PDFHyphenationTest.java
+++ b/flying-saucer-fop/src/test/java/org/xhtmlrenderer/fop/PDFHyphenationTest.java
@@ -18,16 +18,18 @@
*/
package org.xhtmlrenderer.fop;
+import com.codeborne.pdftest.PDF;
+import com.itextpdf.text.DocumentException;
+import org.junit.jupiter.api.Test;
+import org.xhtmlrenderer.pdf.ITextRenderer;
+import org.xhtmlrenderer.pdf.ITextUserAgent;
+
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
-import org.junit.Test;
-import org.xhtmlrenderer.pdf.ITextRenderer;
-import org.xhtmlrenderer.pdf.ITextUserAgent;
-
-import com.itextpdf.text.DocumentException;
+import static com.codeborne.pdftest.assertj.Assertions.assertThat;
/**
* @author Lukas Zaruba, lukas.zaruba@gmail.com
@@ -64,11 +66,17 @@ public class PDFHyphenationTest {
"