You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2020/11/15 16:58:55 UTC
svn commit: r1883453 - in
/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel: common/
common/function/ documentinterchange/logicalstructure/ fdf/ font/
Author: lehmi
Date: Sun Nov 15 16:58:54 2020
New Revision: 1883453
URL: http://svn.apache.org/viewvc?rev=1883453&view=rev
Log:
PDFBOX-5017: switch test to junit5
Modified:
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestEmbeddedFiles.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNameTreeNode.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNumberTreeNode.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElementTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEncoding.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestTTFParser.java
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/COSArrayListTest.java Sun Nov 15 16:58:54 2020
@@ -15,10 +15,10 @@
*/
package org.apache.pdfbox.pdmodel.common;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -37,8 +37,8 @@ import org.apache.pdfbox.pdmodel.interac
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationHighlight;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink;
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationSquare;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class COSArrayListTest {
// next two entries are to be used for comparison with
@@ -64,7 +64,7 @@ public class COSArrayListTest {
* Create three new different annotations and add them to the Java List/Array as
* well as PDFBox List/Array implementations.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
annotationsList = new ArrayList<>();
PDAnnotationHighlight txtMark = new PDAnnotationHighlight();
@@ -115,14 +115,15 @@ public class COSArrayListTest {
for (int i = 0; i < cosArrayList.size(); i++) {
PDAnnotation annot = cosArrayList.get(i);
- assertEquals("PDAnnotations cosObject at " + i + " shall be equal to index " + i + " of COSArray",
- annotationsArray.get(i), annot.getCOSObject());
+ assertEquals(annotationsArray.get(i), annot.getCOSObject(),
+ "PDAnnotations cosObject at " + i + " shall be equal to index " + i
+ + " of COSArray");
// compare with Java List/Array
- assertEquals("PDAnnotations at " + i + " shall be at index " + i + " of List",
- tbcAnnotationsList.get(i), annot);
- assertEquals("PDAnnotations cosObject at " + i + " shall be at position " + i + " of Array",
- tbcAnnotationsArray[i], annot.getCOSObject());
+ assertEquals(tbcAnnotationsList.get(i), annot,
+ "PDAnnotations at " + i + " shall be at index " + i + " of List");
+ assertEquals(tbcAnnotationsArray[i], annot.getCOSObject(),
+ "PDAnnotations cosObject at " + i + " shall be at position " + i + " of Array");
}
}
@@ -137,14 +138,14 @@ public class COSArrayListTest {
PDAnnotationSquare aSquare = new PDAnnotationSquare();
cosArrayList.add(aSquare);
- assertEquals("List size shall be 5", 5, annotationsList.size());
- assertEquals("COSArray size shall be 5", 5, annotationsArray.size());
+ assertEquals(5, annotationsList.size(), "List size shall be 5");
+ assertEquals(5, annotationsArray.size(), "COSArray size shall be 5");
PDAnnotation annot = annotationsList.get(4);
- assertEquals("Added annotation shall be 4th entry in COSArray",
- 4, annotationsArray.indexOf(annot.getCOSObject()));
- assertEquals("Provided COSArray and underlying COSArray shall be equal", annotationsArray,
- cosArrayList.toList());
+ assertEquals(4, annotationsArray.indexOf(annot.getCOSObject()),
+ "Added annotation shall be 4th entry in COSArray");
+ assertEquals(annotationsArray, cosArrayList.toList(),
+ "Provided COSArray and underlying COSArray shall be equal");
}
/**
@@ -157,15 +158,15 @@ public class COSArrayListTest {
int positionToRemove = 2;
PDAnnotation toBeRemoved = cosArrayList.get(positionToRemove);
- assertEquals("Remove operation shall return the removed object", toBeRemoved,
- cosArrayList.remove(positionToRemove));
- assertEquals("List size shall be 3", 3, cosArrayList.size());
- assertEquals("COSArray size shall be 3", 3, annotationsArray.size());
-
- assertEquals("PDAnnotation shall no longer exist in List",
- -1, cosArrayList.indexOf(tbcAnnotationsList.get(positionToRemove)));
- assertEquals("COSObject shall no longer exist in COSArray",
- -1, annotationsArray.indexOf(tbcAnnotationsArray[positionToRemove]));
+ assertEquals(toBeRemoved, cosArrayList.remove(positionToRemove),
+ "Remove operation shall return the removed object");
+ assertEquals(3, cosArrayList.size(), "List size shall be 3");
+ assertEquals(3, annotationsArray.size(), "COSArray size shall be 3");
+
+ assertEquals(-1, cosArrayList.indexOf(tbcAnnotationsList.get(positionToRemove)),
+ "PDAnnotation shall no longer exist in List");
+ assertEquals(-1, annotationsArray.indexOf(tbcAnnotationsArray[positionToRemove]),
+ "COSObject shall no longer exist in COSArray");
}
/**
@@ -179,24 +180,24 @@ public class COSArrayListTest {
int positionToRemove = 2;
PDAnnotation toBeRemoved = annotationsList.get(positionToRemove);
- assertTrue("Remove operation shall return true", cosArrayList.remove(toBeRemoved));
- assertEquals("List size shall be 3", 3, cosArrayList.size());
- assertEquals("COSArray size shall be 3", 3, annotationsArray.size());
+ assertTrue(cosArrayList.remove(toBeRemoved), "Remove operation shall return true");
+ assertEquals(3, cosArrayList.size(), "List size shall be 3");
+ assertEquals(3, annotationsArray.size(), "COSArray size shall be 3");
// compare with Java List/Array to ensure correct object at position
- assertEquals("List object at 3 is at position 2 in COSArrayList now",
- cosArrayList.get(2), tbcAnnotationsList.get(3));
- assertEquals("COSObject of List object at 3 is at position 2 in COSArray now",
- annotationsArray.get(2), tbcAnnotationsList.get(3).getCOSObject());
- assertEquals("Array object at 3 is at position 2 in underlying COSArray now",
- annotationsArray.get(2), tbcAnnotationsArray[3]);
-
- assertEquals("PDAnnotation shall no longer exist in List",
- -1, cosArrayList.indexOf(tbcAnnotationsList.get(positionToRemove)));
- assertEquals("COSObject shall no longer exist in COSArray",
- -1, annotationsArray.indexOf(tbcAnnotationsArray[positionToRemove]));
+ assertEquals(cosArrayList.get(2), tbcAnnotationsList.get(3),
+ "List object at 3 is at position 2 in COSArrayList now");
+ assertEquals(annotationsArray.get(2), tbcAnnotationsList.get(3).getCOSObject(),
+ "COSObject of List object at 3 is at position 2 in COSArray now");
+ assertEquals(annotationsArray.get(2), tbcAnnotationsArray[3],
+ "Array object at 3 is at position 2 in underlying COSArray now");
+
+ assertEquals(-1, cosArrayList.indexOf(tbcAnnotationsList.get(positionToRemove)),
+ "PDAnnotation shall no longer exist in List");
+ assertEquals(-1, annotationsArray.indexOf(tbcAnnotationsArray[positionToRemove]),
+ "COSObject shall no longer exist in COSArray");
- assertFalse("Remove shall not remove any object", cosArrayList.remove(toBeRemoved));
+ assertFalse(cosArrayList.remove(toBeRemoved), "Remove shall not remove any object");
}
@@ -213,11 +214,13 @@ public class COSArrayListTest {
List<PDAnnotation> toBeRemovedInstances = Collections.singletonList(toBeRemoved);
- assertTrue("Remove operation shall return true", cosArrayList.removeAll(toBeRemovedInstances));
- assertEquals("List size shall be 3", 3, cosArrayList.size());
- assertEquals("COSArray size shall be 3", 3, annotationsArray.size());
+ assertTrue(cosArrayList.removeAll(toBeRemovedInstances),
+ "Remove operation shall return true");
+ assertEquals(3, cosArrayList.size(), "List size shall be 3");
+ assertEquals(3, annotationsArray.size(), "COSArray size shall be 3");
- assertFalse("Remove shall not remove any object", cosArrayList.removeAll(toBeRemovedInstances));
+ assertFalse(cosArrayList.removeAll(toBeRemovedInstances),
+ "Remove shall not remove any object");
}
/**
@@ -231,13 +234,13 @@ public class COSArrayListTest {
int positionToRemove = 1;
PDAnnotation toBeRemoved = tbcAnnotationsList.get(positionToRemove);
- assertTrue("Remove operation shall return true", cosArrayList.remove(toBeRemoved));
- assertEquals("List size shall be 3", 3, cosArrayList.size());
- assertEquals("COSArray size shall be 3", 3, annotationsArray.size());
-
- assertTrue("Remove operation shall return true", cosArrayList.remove(toBeRemoved));
- assertEquals("List size shall be 2", 2, cosArrayList.size());
- assertEquals("COSArray size shall be 2", 2, annotationsArray.size());
+ assertTrue(cosArrayList.remove(toBeRemoved), "Remove operation shall return true");
+ assertEquals(3, cosArrayList.size(), "List size shall be 3");
+ assertEquals(3, annotationsArray.size(), "COSArray size shall be 3");
+
+ assertTrue(cosArrayList.remove(toBeRemoved), "Remove operation shall return true");
+ assertEquals(2, cosArrayList.size(), "List size shall be 2");
+ assertEquals(2, annotationsArray.size(), "COSArray size shall be 2");
}
/**
@@ -253,11 +256,13 @@ public class COSArrayListTest {
List<PDAnnotation> toBeRemovedInstances = Collections.singletonList(toBeRemoved);
- assertTrue("Remove operation shall return true", cosArrayList.removeAll(toBeRemovedInstances));
- assertEquals("List size shall be 2", 2, cosArrayList.size());
- assertEquals("COSArray size shall be 2", 2, annotationsArray.size());
+ assertTrue(cosArrayList.removeAll(toBeRemovedInstances),
+ "Remove operation shall return true");
+ assertEquals(2, cosArrayList.size(), "List size shall be 2");
+ assertEquals(2, annotationsArray.size(), "COSArray size shall be 2");
- assertFalse("Remove shall not remove any object", cosArrayList.removeAll(toBeRemovedInstances));
+ assertFalse(cosArrayList.removeAll(toBeRemovedInstances),
+ "Remove shall not remove any object");
}
@Test
@@ -308,7 +313,7 @@ public class COSArrayListTest {
pageAnnots.add(txtMark);
pageAnnots.add(txtMark);
pageAnnots.add(txtLink);
- assertEquals("There shall be 4 annotations generated", 4, pageAnnots.size());
+ assertEquals(4, pageAnnots.size(), "There shall be 4 annotations generated");
page.setAnnotations(pageAnnots);
@@ -320,14 +325,16 @@ public class COSArrayListTest {
COSArrayList<PDAnnotation> annotations = (COSArrayList) page.getAnnotations();
- assertEquals("There shall be 4 annotations retrieved", 4, annotations.size());
- assertEquals("The size of the internal COSArray shall be 4", 4, annotations.toList().size());
+ assertEquals(4, annotations.size(), "There shall be 4 annotations retrieved");
+ assertEquals(4, annotations.toList().size(),
+ "The size of the internal COSArray shall be 4");
PDAnnotation toBeRemoved = annotations.get(0);
annotations.remove(toBeRemoved);
- assertEquals("There shall be 3 annotations left", 3, annotations.size());
- assertEquals("The size of the internal COSArray shall be 3", 3, annotations.toList().size());
+ assertEquals(3, annotations.size(), "There shall be 3 annotations left");
+ assertEquals(3, annotations.toList().size(),
+ "The size of the internal COSArray shall be 3");
}
}
@@ -347,7 +354,7 @@ public class COSArrayListTest {
pageAnnots.add(txtMark);
pageAnnots.add(txtMark);
pageAnnots.add(txtLink);
- assertEquals("There shall be 4 annotations generated", 4, pageAnnots.size());
+ assertEquals(4, pageAnnots.size(), "There shall be 4 annotations generated");
page.setAnnotations(pageAnnots);
@@ -359,15 +366,17 @@ public class COSArrayListTest {
COSArrayList<PDAnnotation> annotations = (COSArrayList) page.getAnnotations();
- assertEquals("There shall be 4 annotations retrieved", 4, annotations.size());
- assertEquals("The size of the internal COSArray shall be 4", 4, annotations.toList().size());
+ assertEquals(4, annotations.size(), "There shall be 4 annotations retrieved");
+ assertEquals(4, annotations.toList().size(),
+ "The size of the internal COSArray shall be 4");
PDAnnotation toBeRemoved = annotations.get(0);
annotations.remove(toBeRemoved);
- assertEquals("There shall be 3 annotations left", 3, annotations.size());
- assertEquals("The size of the internal COSArray shall be 2", 3, annotations.toList().size());
+ assertEquals(3, annotations.size(), "There shall be 3 annotations left");
+ assertEquals(3, annotations.toList().size(),
+ "The size of the internal COSArray shall be 2");
}
}
@@ -387,7 +396,7 @@ public class COSArrayListTest {
pageAnnots.add(txtMark);
pageAnnots.add(txtMark);
pageAnnots.add(txtLink);
- assertEquals("There shall be 4 annotations generated", 4, pageAnnots.size());
+ assertEquals(4, pageAnnots.size(), "There shall be 4 annotations generated");
page.setAnnotations(pageAnnots);
@@ -399,16 +408,18 @@ public class COSArrayListTest {
COSArrayList<PDAnnotation> annotations = (COSArrayList) page.getAnnotations();
- assertEquals("There shall be 4 annotations retrieved", 4, annotations.size());
- assertEquals("The size of the internal COSArray shall be 4", 4, annotations.toList().size());
+ assertEquals(4, annotations.size(), "There shall be 4 annotations retrieved");
+ assertEquals(4, annotations.toList().size(),
+ "The size of the internal COSArray shall be 4");
ArrayList<PDAnnotation> toBeRetained = new ArrayList<>();
toBeRetained.add(annotations.get(0));
annotations.retainAll(toBeRetained);
- assertEquals("There shall be 3 annotations left", 3, annotations.size());
- assertEquals("The size of the internal COSArray shall be 3", 3, annotations.toList().size());
+ assertEquals(3, annotations.size(), "There shall be 3 annotations left");
+ assertEquals(3, annotations.toList().size(),
+ "The size of the internal COSArray shall be 3");
}
}
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/PDStreamTest.java Sun Nov 15 16:58:54 2020
@@ -15,6 +15,9 @@
*/
package org.apache.pdfbox.pdmodel.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
@@ -22,8 +25,7 @@ import java.util.List;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
@@ -42,17 +44,17 @@ public class PDStreamTest
{
InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
PDStream pdStream = new PDStream(doc, is, (COSArray) null);
- Assert.assertTrue(pdStream.getFilters().isEmpty());
+ assertTrue(pdStream.getFilters().isEmpty());
List<String> stopFilters = new ArrayList<>();
stopFilters.add(COSName.DCT_DECODE.toString());
stopFilters.add(COSName.DCT_DECODE_ABBREVIATION.toString());
is = pdStream.createInputStream(stopFilters);
- Assert.assertEquals(12,is.read());
- Assert.assertEquals(34,is.read());
- Assert.assertEquals(56,is.read());
- Assert.assertEquals(78,is.read());
- Assert.assertEquals(-1,is.read());
+ assertEquals(12,is.read());
+ assertEquals(34,is.read());
+ assertEquals(56,is.read());
+ assertEquals(78,is.read());
+ assertEquals(-1,is.read());
}
}
@@ -66,17 +68,17 @@ public class PDStreamTest
{
InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
PDStream pdStream = new PDStream(doc, is, new COSArray());
- Assert.assertEquals(0,pdStream.getFilters().size());
+ assertEquals(0,pdStream.getFilters().size());
List<String> stopFilters = new ArrayList<>();
stopFilters.add(COSName.DCT_DECODE.toString());
stopFilters.add(COSName.DCT_DECODE_ABBREVIATION.toString());
is = pdStream.createInputStream(stopFilters);
- Assert.assertEquals(12,is.read());
- Assert.assertEquals(34,is.read());
- Assert.assertEquals(56,is.read());
- Assert.assertEquals(78,is.read());
- Assert.assertEquals(-1,is.read());
+ assertEquals(12,is.read());
+ assertEquals(34,is.read());
+ assertEquals(56,is.read());
+ assertEquals(78,is.read());
+ assertEquals(-1,is.read());
}
}
@@ -90,14 +92,14 @@ public class PDStreamTest
{
InputStream is = new ByteArrayInputStream(new byte[] { 12, 34, 56, 78 });
PDStream pdStream = new PDStream(doc, is, new COSArray());
- Assert.assertEquals(0, pdStream.getFilters().size());
+ assertEquals(0, pdStream.getFilters().size());
is = pdStream.createInputStream((List<String>) null);
- Assert.assertEquals(12, is.read());
- Assert.assertEquals(34, is.read());
- Assert.assertEquals(56, is.read());
- Assert.assertEquals(78,is.read());
- Assert.assertEquals(-1,is.read());
+ assertEquals(12, is.read());
+ assertEquals(34, is.read());
+ assertEquals(56, is.read());
+ assertEquals(78,is.read());
+ assertEquals(-1,is.read());
}
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestEmbeddedFiles.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestEmbeddedFiles.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestEmbeddedFiles.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestEmbeddedFiles.java Sun Nov 15 16:58:54 2020
@@ -16,6 +16,12 @@
*/
package org.apache.pdfbox.pdmodel.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
@@ -28,11 +34,9 @@ import org.apache.pdfbox.pdmodel.PDDocum
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
-import org.junit.Test;
-
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class TestEmbeddedFiles extends TestCase
+public class TestEmbeddedFiles
{
@Test
public void testNullEmbeddedFile() throws IOException
@@ -47,7 +51,7 @@ public class TestEmbeddedFiles extends T
PDDocumentCatalog catalog = doc.getDocumentCatalog();
PDDocumentNameDictionary names = catalog.getNames();
- assertEquals("expected two files", 2, names.getEmbeddedFiles().getNames().size());
+ assertEquals(2, names.getEmbeddedFiles().getNames().size(), "expected two files");
PDEmbeddedFilesNameTreeNode embeddedFiles = names.getEmbeddedFiles();
PDComplexFileSpecification spec = embeddedFiles.getNames().get("non-existent-file.docx");
@@ -59,16 +63,16 @@ public class TestEmbeddedFiles extends T
}
//now test for actual attachment
spec = embeddedFiles.getNames().get("My first attachment");
- assertNotNull("one attachment actually exists", spec);
- assertEquals("existing file length", 17660, spec.getEmbeddedFile().getLength());
+ assertNotNull(spec, "one attachment actually exists");
+ assertEquals(17660, spec.getEmbeddedFile().getLength(), "existing file length");
spec = embeddedFiles.getNames().get("non-existent-file.docx");
}
catch (NullPointerException e)
{
- assertNotNull("null pointer exception", null);
+ fail("null pointer exception");
}
- assertTrue("Was able to get file without exception", ok);
- assertNull("EmbeddedFile was correctly null", embeddedFile);
+ assertTrue(ok, "Was able to get file without exception");
+ assertNull(embeddedFile, "EmbeddedFile was correctly null");
}
@Test
@@ -99,15 +103,14 @@ public class TestEmbeddedFiles extends T
unixFile = spec.getEmbeddedFileUnix();
}
- assertTrue("non os specific",
- byteArrayContainsLC("non os specific", nonOSFile.toByteArray(), "ISO-8859-1"));
-
- assertTrue("mac", byteArrayContainsLC("mac embedded", macFile.toByteArray(), "ISO-8859-1"));
+ assertTrue(byteArrayContainsLC("non os specific", nonOSFile.toByteArray(), "ISO-8859-1"),
+ "non os specific");
+ assertTrue(byteArrayContainsLC("mac embedded", macFile.toByteArray(), "ISO-8859-1"), "mac");
- assertTrue("dos", byteArrayContainsLC("dos embedded", dosFile.toByteArray(), "ISO-8859-1"));
+ assertTrue(byteArrayContainsLC("dos embedded", dosFile.toByteArray(), "ISO-8859-1"), "dos");
- assertTrue("unix",
- byteArrayContainsLC("unix embedded", unixFile.toByteArray(), "ISO-8859-1"));
+ assertTrue(byteArrayContainsLC("unix embedded", unixFile.toByteArray(), "ISO-8859-1"),
+ "unix");
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNameTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNameTreeNode.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNameTreeNode.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNameTreeNode.java Sun Nov 15 16:58:54 2020
@@ -16,20 +16,22 @@
*/
package org.apache.pdfbox.pdmodel.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import junit.framework.TestCase;
import org.apache.pdfbox.cos.COSInteger;
-import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* A test case for PDNameTreeNode.
*
* @author Koch
*/
-public class TestPDNameTreeNode extends TestCase
+public class TestPDNameTreeNode
{
private PDNameTreeNode<COSInteger> node1;
private PDNameTreeNode<COSInteger> node2;
@@ -37,7 +39,7 @@ public class TestPDNameTreeNode extends
private PDNameTreeNode<COSInteger> node5;
private PDNameTreeNode<COSInteger> node24;
- @Override
+ @BeforeEach
protected void setUp() throws Exception
{
this.node5 = new PDIntegerNameTreeNode();
@@ -89,25 +91,27 @@ public class TestPDNameTreeNode extends
this.node1.setKids(kids);
}
+ @Test
public void testUpperLimit() throws IOException
{
- Assert.assertEquals("Astatine", this.node5.getUpperLimit());
- Assert.assertEquals("Astatine", this.node2.getUpperLimit());
+ assertEquals("Astatine", this.node5.getUpperLimit());
+ assertEquals("Astatine", this.node2.getUpperLimit());
- Assert.assertEquals("Zirconium", this.node24.getUpperLimit());
- Assert.assertEquals("Zirconium", this.node4.getUpperLimit());
+ assertEquals("Zirconium", this.node24.getUpperLimit());
+ assertEquals("Zirconium", this.node4.getUpperLimit());
- Assert.assertEquals(null, this.node1.getUpperLimit());
+ assertEquals(null, this.node1.getUpperLimit());
}
+ @Test
public void testLowerLimit() throws IOException
{
- Assert.assertEquals("Actinium", this.node5.getLowerLimit());
- Assert.assertEquals("Actinium", this.node2.getLowerLimit());
+ assertEquals("Actinium", this.node5.getLowerLimit());
+ assertEquals("Actinium", this.node2.getLowerLimit());
- Assert.assertEquals("Xenon", this.node24.getLowerLimit());
- Assert.assertEquals("Xenon", this.node4.getLowerLimit());
+ assertEquals("Xenon", this.node24.getLowerLimit());
+ assertEquals("Xenon", this.node4.getLowerLimit());
- Assert.assertEquals(null, this.node1.getLowerLimit());
+ assertEquals(null, this.node1.getLowerLimit());
}
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNumberTreeNode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNumberTreeNode.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNumberTreeNode.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/TestPDNumberTreeNode.java Sun Nov 15 16:58:54 2020
@@ -16,14 +16,17 @@
*/
package org.apache.pdfbox.pdmodel.common;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import junit.framework.TestCase;
import org.apache.pdfbox.cos.COSInteger;
-import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* A test case for PDNumberTreeNode.
@@ -31,7 +34,7 @@ import org.junit.Assert;
*
* @author Dominic Tubach
*/
-public class TestPDNumberTreeNode extends TestCase
+public class TestPDNumberTreeNode
{
private PDNumberTreeNode node1;
@@ -89,8 +92,8 @@ public class TestPDNumberTreeNode extend
}
}
- @Override
- protected void setUp() throws Exception
+ @BeforeEach
+ protected void setUp()
{
this.node5 = new PDNumberTreeNode(PDTest.class);
Map<Integer,PDTest> Numbers = new TreeMap<>();
@@ -141,54 +144,57 @@ public class TestPDNumberTreeNode extend
this.node1.setKids( kids );
}
+ @Test
public void testGetValue() throws IOException
{
- Assert.assertEquals(new PDTest( 51 ), this.node5.getValue( 4 ));
- Assert.assertEquals(new PDTest(70), this.node1.getValue( 9 ));
+ assertEquals(new PDTest( 51 ), this.node5.getValue( 4 ));
+ assertEquals(new PDTest(70), this.node1.getValue( 9 ));
this.node1.setKids( null );
this.node1.setNumbers( null );
- Assert.assertNull( this.node1.getValue( 0 ) );
+ assertNull( this.node1.getValue( 0 ) );
}
+ @Test
public void testUpperLimit() throws IOException
{
- Assert.assertEquals(7, (int) this.node5.getUpperLimit());
- Assert.assertEquals(7, (int) this.node2.getUpperLimit());
+ assertEquals(7, (int) this.node5.getUpperLimit());
+ assertEquals(7, (int) this.node2.getUpperLimit());
- Assert.assertEquals(12, (int) this.node24.getUpperLimit());
- Assert.assertEquals(12, (int) this.node4.getUpperLimit());
+ assertEquals(12, (int) this.node24.getUpperLimit());
+ assertEquals(12, (int) this.node4.getUpperLimit());
- Assert.assertEquals(12, (int) this.node1.getUpperLimit());
+ assertEquals(12, (int) this.node1.getUpperLimit());
this.node24.setNumbers(new HashMap<>());
- Assert.assertNull( this.node24.getUpperLimit() );
+ assertNull( this.node24.getUpperLimit() );
this.node5.setNumbers( null );
- Assert.assertNull( this.node5.getUpperLimit() );
+ assertNull( this.node5.getUpperLimit() );
this.node1.setKids( null );
- Assert.assertNull( this.node1.getUpperLimit() );
+ assertNull( this.node1.getUpperLimit() );
}
+ @Test
public void testLowerLimit() throws IOException
{
- Assert.assertEquals(1, (int) this.node5.getLowerLimit());
- Assert.assertEquals(1, (int) this.node2.getLowerLimit());
+ assertEquals(1, (int) this.node5.getLowerLimit());
+ assertEquals(1, (int) this.node2.getLowerLimit());
- Assert.assertEquals(8, (int) this.node24.getLowerLimit());
- Assert.assertEquals(8, (int) this.node4.getLowerLimit());
+ assertEquals(8, (int) this.node24.getLowerLimit());
+ assertEquals(8, (int) this.node4.getLowerLimit());
- Assert.assertEquals(1, (int) this.node1.getLowerLimit());
+ assertEquals(1, (int) this.node1.getLowerLimit());
this.node24.setNumbers(new HashMap<>());
- Assert.assertNull( this.node24.getLowerLimit() );
+ assertNull( this.node24.getLowerLimit() );
this.node5.setNumbers( null );
- Assert.assertNull( this.node5.getLowerLimit() );
+ assertNull( this.node5.getLowerLimit() );
this.node1.setKids( null );
- Assert.assertNull( this.node1.getLowerLimit() );
+ assertNull( this.node1.getLowerLimit() );
}
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/common/function/TestPDFunctionType4.java Sun Nov 15 16:58:54 2020
@@ -16,17 +16,19 @@
*/
package org.apache.pdfbox.pdmodel.common.function;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
-import junit.framework.TestCase;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSStream;
+import org.junit.jupiter.api.Test;
/**
* Tests the {@link PDFunctionType4} class.
*/
-public class TestPDFunctionType4 extends TestCase
+public class TestPDFunctionType4
{
private PDFunctionType4 createFunction(String function, float[] domain, float[] range)
@@ -54,6 +56,7 @@ public class TestPDFunctionType4 extends
* Checks the {@link PDFunctionType4}.
* @throws Exception if an error occurs
*/
+ @Test
public void testFunctionSimple() throws Exception
{
String functionText = "{ add }";
@@ -86,6 +89,7 @@ public class TestPDFunctionType4 extends
* Checks the handling of the argument order for a {@link PDFunctionType4}.
* @throws Exception if an error occurs
*/
+ @Test
public void testFunctionArgumentOrder() throws Exception
{
String functionText = "{ pop }";
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElementTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElementTest.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElementTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureElementTest.java Sun Nov 15 16:58:54 2020
@@ -16,6 +16,8 @@
*/
package org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
@@ -28,8 +30,7 @@ import org.apache.pdfbox.cos.COSDictiona
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSObject;
import org.apache.pdfbox.pdmodel.PDDocument;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
@@ -55,13 +56,13 @@ public class PDStructureElementTest
}
// collect attributes and check their count.
- Assert.assertEquals(117, attributeSet.size());
+ assertEquals(117, attributeSet.size());
int cnt = 0;
for (Revisions<PDAttributeObject> attributes : attributeSet)
{
cnt += attributes.size();
}
- Assert.assertEquals(111, cnt); // this one was 105 before PDFBOX-4197 was fixed
+ assertEquals(111, cnt); // this one was 105 before PDFBOX-4197 was fixed
}
// Each element can be an array, a dictionary or a number.
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationTest.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotationTest.java Sun Nov 15 16:58:54 2020
@@ -17,16 +17,16 @@
package org.apache.pdfbox.pdmodel.fdf;
import java.io.File;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import org.apache.pdfbox.Loader;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests for the FDFAnnotation class.
@@ -58,7 +58,7 @@ public class FDFAnnotationTest
if ("P&1 P&2 P&3".equals(annotationFreeText.getContents()))
{
testedPDFBox4345andPDFBox3646 = true;
- Assert.assertEquals("<body style=\"font:12pt Helvetica; "
+ assertEquals("<body style=\"font:12pt Helvetica; "
+ "color:#D66C00;\" xfa:APIVersion=\"Acrobat:7.0.8\" "
+ "xfa:spec=\"2.0.2\" xmlns=\"http://www.w3.org/1999/xhtml\" "
+ "xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\">\n"
@@ -69,7 +69,7 @@ public class FDFAnnotationTest
}
}
}
- Assert.assertTrue(testedPDFBox4345andPDFBox3646);
+ assertTrue(testedPDFBox4345andPDFBox3646);
}
}
}
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/fdf/FDFFieldTest.java Sun Nov 15 16:58:54 2020
@@ -17,7 +17,7 @@
package org.apache.pdfbox.pdmodel.fdf;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.io.OutputStream;
@@ -29,7 +29,7 @@ import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.cos.COSString;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/*
* Test some characteristics of FDFFields
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/PDFontTest.java Sun Nov 15 16:58:54 2020
@@ -17,6 +17,11 @@
package org.apache.pdfbox.pdmodel.font;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -40,9 +45,8 @@ import org.apache.pdfbox.pdmodel.PDPageC
import org.apache.pdfbox.pdmodel.font.encoding.WinAnsiEncoding;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.apache.pdfbox.text.PDFTextStripper;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
*
@@ -53,7 +57,7 @@ public class PDFontTest
{
private static final File OUT_DIR = new File("target/test-output");
- @Before
+ @BeforeEach
public void setUp() throws Exception
{
OUT_DIR.mkdirs();
@@ -113,7 +117,7 @@ public class PDFontTest
{
PDFTextStripper stripper = new PDFTextStripper();
String text = stripper.getText(doc);
- Assert.assertEquals("PDFBOX-3747", text.trim());
+ assertEquals("PDFBOX-3747", text.trim());
}
}
@@ -177,17 +181,17 @@ public class PDFontTest
try (PDDocument doc = Loader.loadPDF(outputFile))
{
PDType1Font font = (PDType1Font) doc.getPage(0).getResources().getFont(COSName.getPDFName("F1"));
- Assert.assertEquals(WinAnsiEncoding.INSTANCE, font.getEncoding());
+ assertEquals(WinAnsiEncoding.INSTANCE, font.getEncoding());
for (char c : text.toCharArray())
{
String name = font.getEncoding().getName(c);
- Assert.assertEquals("dieresis", name.substring(1));
- Assert.assertFalse(font.getPath(name).getBounds2D().isEmpty());
+ assertEquals("dieresis", name.substring(1));
+ assertFalse(font.getPath(name).getBounds2D().isEmpty());
}
PDFTextStripper stripper = new PDFTextStripper();
- Assert.assertEquals(text, stripper.getText(doc).trim());
+ assertEquals(text, stripper.getText(doc).trim());
}
}
@@ -198,13 +202,13 @@ public class PDFontTest
@Test
public void testPDFox4318() throws IOException
{
- Assert.assertThrows("should have thrown IllegalArgumentException",
- IllegalArgumentException.class,
- () -> PDType1Font.HELVETICA_BOLD.encode("\u0080"));
+ assertThrows(IllegalArgumentException.class,
+ () -> PDType1Font.HELVETICA_BOLD.encode("\u0080"),
+ "should have thrown IllegalArgumentException");
PDType1Font.HELVETICA_BOLD.encode("â¬");
- Assert.assertThrows("should have thrown IllegalArgumentException",
- IllegalArgumentException.class,
- () -> PDType1Font.HELVETICA_BOLD.encode("\u0080"));
+ assertThrows(IllegalArgumentException.class,
+ () -> PDType1Font.HELVETICA_BOLD.encode("\u0080"),
+ "should have thrown IllegalArgumentException");
}
@Test
@@ -238,10 +242,10 @@ public class PDFontTest
TrueTypeFont ttf = ttc.getFontByName(names.get(0)); // take the first one
System.out.println("TrueType font used for test: " + ttf.getName());
- IOException ex = Assert.assertThrows("should have thrown IOException",
- IOException.class,
- () -> PDType0Font.load(new PDDocument(), ttf, false));
- Assert.assertEquals("Full embedding of TrueType font collections not supported", ex.getMessage());
+ IOException ex = assertThrows(IOException.class,
+ () -> PDType0Font.load(new PDDocument(), ttf, false),
+ "should have thrown IOException");
+ assertEquals("Full embedding of TrueType font collections not supported", ex.getMessage());
}
private void testPDFBox3826checkFonts(byte[] byteArray, File fontFile) throws IOException
@@ -252,25 +256,25 @@ public class PDFontTest
// F1 = type0 subset
PDType0Font fontF1 = (PDType0Font) page2.getResources().getFont(COSName.getPDFName("F1"));
- Assert.assertTrue(fontF1.getName().contains("+"));
- Assert.assertTrue(fontFile.length() > fontF1.getFontDescriptor().getFontFile2().toByteArray().length);
+ assertTrue(fontF1.getName().contains("+"));
+ assertTrue(fontFile.length() > fontF1.getFontDescriptor().getFontFile2().toByteArray().length);
// F2 = type0 full embed
PDType0Font fontF2 = (PDType0Font) page2.getResources().getFont(COSName.getPDFName("F2"));
- Assert.assertFalse(fontF2.getName().contains("+"));
- Assert.assertEquals(fontFile.length(), fontF2.getFontDescriptor().getFontFile2().toByteArray().length);
+ assertFalse(fontF2.getName().contains("+"));
+ assertEquals(fontFile.length(), fontF2.getFontDescriptor().getFontFile2().toByteArray().length);
// F3 = tt full embed
PDTrueTypeFont fontF3 = (PDTrueTypeFont) page2.getResources().getFont(COSName.getPDFName("F3"));
- Assert.assertFalse(fontF2.getName().contains("+"));
- Assert.assertEquals(fontFile.length(), fontF3.getFontDescriptor().getFontFile2().toByteArray().length);
+ assertFalse(fontF2.getName().contains("+"));
+ assertEquals(fontFile.length(), fontF3.getFontDescriptor().getFontFile2().toByteArray().length);
new PDFRenderer(doc).renderImage(0);
PDFTextStripper stripper = new PDFTextStripper();
stripper.setLineSeparator("\n");
String text = stripper.getText(doc);
- Assert.assertEquals("testMultipleFontFileReuse1\ntestMultipleFontFileReuse2\ntestMultipleFontFileReuse3", text.trim());
+ assertEquals("testMultipleFontFileReuse1\ntestMultipleFontFileReuse2\ntestMultipleFontFileReuse3", text.trim());
}
}
@@ -351,7 +355,7 @@ public class PDFontTest
{
PDFTextStripper stripper = new PDFTextStripper();
String extractedText = stripper.getText(doc);
- Assert.assertEquals(text, extractedText.trim());
+ assertEquals(text, extractedText.trim());
}
Files.delete(tempPdfFile.toPath());
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEmbedding.java Sun Nov 15 16:58:54 2020
@@ -17,12 +17,14 @@
package org.apache.pdfbox.pdmodel.font;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.TestCase;
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.cos.COSArray;
@@ -34,6 +36,8 @@ import org.apache.pdfbox.pdmodel.common.
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.rendering.TestPDFToImage;
import org.apache.pdfbox.text.PDFTextStripper;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Tests font embedding.
@@ -41,11 +45,11 @@ import org.apache.pdfbox.text.PDFTextStr
* @author John Hewson
* @author Tilman Hausherr
*/
-public class TestFontEmbedding extends TestCase
+public class TestFontEmbedding
{
private static final File OUT_DIR = new File("target/test-output");
- @Override
+ @BeforeEach
protected void setUp()
{
OUT_DIR.mkdirs();
@@ -56,6 +60,7 @@ public class TestFontEmbedding extends T
*
* @throws IOException
*/
+ @Test
public void testCIDFontType2() throws IOException
{
validateCIDFontType2(false);
@@ -66,6 +71,7 @@ public class TestFontEmbedding extends T
*
* @throws IOException
*/
+ @Test
public void testCIDFontType2Subset() throws IOException
{
validateCIDFontType2(true);
@@ -76,6 +82,7 @@ public class TestFontEmbedding extends T
*
* @throws IOException
*/
+ @Test
public void testCIDFontType2VerticalSubsetMonospace() throws IOException
{
String text = "ãABCã";
@@ -124,6 +131,7 @@ public class TestFontEmbedding extends T
*
* @throws IOException
*/
+ @Test
public void testCIDFontType2VerticalSubsetProportional() throws IOException
{
String text = "ãABCã";
@@ -175,6 +183,7 @@ public class TestFontEmbedding extends T
assertEquals(expectedExtractedtext, extracted.replaceAll("\r", "").trim());
}
+ @Test
public void testBengali() throws IOException
{
String BANGLA_TEXT_1 = "à¦à¦®à¦¿ à¦à§à¦¨ পথৠà¦à§à¦·à§à¦°à§à¦° লà¦à§à¦·à§à¦®à§ ষনà§à¦¡ পà§à¦¤à§à¦² রà§à¦ªà§ à¦à¦à§à¦à¦¾ à¦à¦·à¦¿";
@@ -227,6 +236,7 @@ public class TestFontEmbedding extends T
*
* @throws java.io.IOException
*/
+ @Test
public void testMaxEntries() throws IOException
{
File file;
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEncoding.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEncoding.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestFontEncoding.java Sun Nov 15 16:58:54 2020
@@ -17,11 +17,12 @@
package org.apache.pdfbox.pdmodel.font;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import junit.framework.TestCase;
-
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSDictionary;
@@ -34,16 +35,18 @@ import org.apache.pdfbox.pdmodel.font.en
import org.apache.pdfbox.pdmodel.font.encoding.MacRomanEncoding;
import org.apache.pdfbox.pdmodel.font.encoding.WinAnsiEncoding;
import org.apache.pdfbox.text.PDFTextStripper;
+import org.junit.jupiter.api.Test;
/**
* Tests font encoding.
*
*/
-public class TestFontEncoding extends TestCase
+public class TestFontEncoding
{
/**
* Test the add method of a font encoding.
*/
+ @Test
public void testAdd() throws Exception
{
// see PDFDBOX-3332
@@ -54,6 +57,7 @@ public class TestFontEncoding extends Te
assertEquals(32, codeForSpace);
}
+ @Test
public void testOverwrite() throws Exception
{
// see PDFDBOX-3332
@@ -75,6 +79,7 @@ public class TestFontEncoding extends Te
*
* @throws IOException
*/
+ @Test
public void testPDFBox3884() throws IOException
{
PDDocument doc = new PDDocument();
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestTTFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestTTFParser.java?rev=1883453&r1=1883452&r2=1883453&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestTTFParser.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/font/TestTTFParser.java Sun Nov 15 16:58:54 2020
@@ -16,6 +16,9 @@
*/
package org.apache.pdfbox.pdmodel.font;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import java.io.IOException;
import java.io.InputStream;
import org.apache.fontbox.ttf.CmapSubtable;
@@ -24,8 +27,7 @@ import org.apache.fontbox.ttf.NameRecord
import org.apache.fontbox.ttf.PostScriptTable;
import org.apache.fontbox.ttf.TTFParser;
import org.apache.fontbox.ttf.TrueTypeFont;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* A test for correctly parsing TTF files.
@@ -43,16 +45,16 @@ public class TestTTFParser
{
InputStream input = PDFont.class.getResourceAsStream(
"/org/apache/pdfbox/resources/ttf/LiberationSans-Regular.ttf");
- Assert.assertNotNull(input);
+ assertNotNull(input);
TTFParser parser = new TTFParser();
TrueTypeFont font = parser.parse(input);
CmapTable cmapTable = font.getCmap();
- Assert.assertNotNull(cmapTable);
+ assertNotNull(cmapTable);
CmapSubtable[] cmaps = cmapTable.getCmaps();
- Assert.assertNotNull(cmaps);
+ assertNotNull(cmaps);
CmapSubtable cmap = null;
@@ -66,20 +68,20 @@ public class TestTTFParser
}
}
- Assert.assertNotNull(cmap);
+ assertNotNull(cmap);
PostScriptTable post = font.getPostScript();
- Assert.assertNotNull(post);
+ assertNotNull(post);
String[] glyphNames = font.getPostScript().getGlyphNames();
- Assert.assertNotNull(glyphNames);
+ assertNotNull(glyphNames);
// test a WGL4 (Macintosh standard) name
int gid = cmap.getGlyphId(0x2122); // TRADE MARK SIGN
- Assert.assertEquals("trademark", glyphNames[gid]);
+ assertEquals("trademark", glyphNames[gid]);
// test an additional name
gid = cmap.getGlyphId(0x20AC); // EURO SIGN
- Assert.assertEquals("Euro", glyphNames[gid]);
+ assertEquals("Euro", glyphNames[gid]);
}
}